Running 2 stepper motors & 1 servo with an Arduino

People have asked about the code in my short video showing an Arduino running two stepper motors and one servo simultaneously. Please look at the bottom of the page for a zip archive of the code/sketch.

YouTube Video


Notes: Each stepper motor needs some sort of driver board or h-bridge chip. Examples are the ULN2003 (Darlington pairs) or the :L293D half-H driver chip. You'll also need to power them with a separate power supply (with the GROUND connected to the Arduino GROUND). The "hobby servo", however, can be powered from the Arduino - I suspect if you use more than one servo, you might need to put THEM on a separate power supply as well.

This code uses the excellent AccelStepper library, which has some advantages over the stock stepper support in the Arduino IDE -- namely, it doesn't have blocking code. You will, however, have to call the stepper object's .run() method once per loop() so that the library can update the position, velocity, etc.

ċ
2steppers1servo.zip
(3k)
Patrick Casey,
Nov 3, 2018, 11:38 AM