Stepper Speed Control
Stepper motors, due to their unique design, can be controlled to a high degree of accuracy without any feedback mechanisms. The shaft of a stepper, mounted with a series of magnets, is controlled by a series of electromagnetic coils that are charged positively and negatively in a specific sequence, precisely moving it forward or backward in small "steps".
There are two types of steppers, Unipolars and Bipolars, and it is very important to know which type you are working with. For each of the motors, there is a different circuit. The example code will control both kinds of motors. See the unipolar and bipolar motor schematics for information on how to wire up your motor.
In this example, a potentiometer (or other sensor) on analog input 0 is used to control the rotational speed of a stepper motor using the Arduino Stepper Library. The stepper is controlled by with digital pins 8, 9, 10, and 11 for either unipolar or bipolar motors.
The Arduino board will connect to a U2004 Darlington Array if you're using a unipolar stepper or a SN754410NE H-Bridge if you have a bipolar motor.
Hardware Required
Arduino Board
10k ohm potentiometer
stepper motor
U2004 Darlington Array (if using a unipolar stepper)
SN754410ne H-Bridge (if using a bipolar stepper)
power supply appropriate for your particular stepper
hook-up wires
breadboard
Circuits
Below you'll find circuits for both unipolar and bipolar steppers. In either case, it is best to power your stepper motors from an external supply, as they draw too much to be powered directly from your Arduino board.
In both circuits, connect a 10k pot to power and ground, with it's wiper outputting to analog pin 0.
Note: Both circuits below are four wire configurations. Two wire configurations will not work with the code provided.
Unipolar Stepper Circuit and schematic
Unipolar Motor Knob Circuit
image developed using Fritzing. For more circuit examples, see the Fritzing project page
Unipolar Motor Knob Schematic
Bipolar Stepper Circuit and schematic
Bipolar Motor Knob Circuit
image developed using Fritzing. For more circuit examples, see the Fritzing project page
Bipolar Motor Knob Schematic
Code
For both unipolar and bipolar steppers
See also
Stepper myStepper = Stepper(steps, pin1, pin2, pin3, pin4)
MotorKnob - Moves the shaft according to the position of the knob of a potentiometer.
StepperOneRevolution - Turn the shaft one revolution clockwise and one counterclockwise.
StepperOneStepAtATime - Single stepping to check the proper wiring of the motor.
Last revision 2018/08/23 by SM