Step 7: Using a Stepper Motor with an Arduino

Picture of Using a Stepper Motor with an Arduino
stepper arduino_guide.jpg
Working with the Arduino coding platform, there is a wide range of example libraries to get you started. Connecting a stepper motor to an Arduino is a different than connecting a DC motor to the board. Because stepper motors have to pulse in a specific way for the rotor to spin, there is a special Stepper library and function built into the Arduino code platform. You can read more about it here.

Opening the Arduino software, browse to "File>Examples>Stepper>stepper_oneRevolution"

This program drives a unipolar or bipolar stepper motor, by attaching the motor to digital pins 8 - 11 of the Arduino. After the sketch is loaded on to the Arduino board, the motor should revolve one revolution clockwise, then one revolution moving counter-clockwise.

The example code is an excellent point to start from, you can certainly make edits to the sketch to suit your needs. The delay is listed in microseconds, so if you want there to be no break between it's revolutions, you can set delay to delay(10). Or if you want it to spin for a long time you can change stepsPerRevolution to equal = (1000000) 

How you modify the sketch will depend on what you are trying to accomplish with the motor. Playing with some of the other sketches in the example sketch library will help you develop a greater understanding of how stepper motors are able to communicate with Arduino Boards.

this is one of the most comprehensive tutorial about how to use a stepper motor with arduino board
Alderin2 years ago
While this is a good rig to experiment with and learn about stepper motors, be careful about the load you put on your Arduino. Steppers and DC Motors can send spikes of current back to the controlling circuitry when switching from on to off due to inductance, as well as possibly drawing more current than your Arduino is designed to supply. For more permanent projects you should get or build a motor control board to isolate the more delicate logic circuits.