[Stepper motor controller]

Stepper Motors

A stepper motor is a motor that moves one tiny step at a time. So you can control exactly how far it rotates in either direction by telling it how many steps to move.

Like all motors, a stepper requires a separate battery -- you can't power it directly off the Arduino. We have the ULN2003 stepper motor driver board, which makes it easier to wire up the battery pack.

We'll try to have shields pre-wired for you, but in case the wires come apart, here's how they need to be wired:

Wire color blue yellow red green
Arduino digital pin 8 9 10 11

Then find the place on the stepper driver board where it says - and + right on top of where it says 5-12V. Wire the red (+) terminal of your battery pack to the + pin. The black (-) terminal of the battery needs to be connected to the - pin, but it also needs to be connected to Gnd on your Arduino circuit.
(Important: don't do that for the red wire from the battery, only the black one! Connecting the red battery lead to the Arduino's 5v pin could kill your Arduino.)

Programming a stepper

Use the Stepper library. There are some samples in the menu File->Examples->Stepper. The simplest is stepper_oneRevolution. Set stepsPerRevolution to 64 and speed to anything up to 100.

#include <Stepper.h>

const int stepsPerRevolution = 64;
// The motor is actually 64 steps per revolution, but then it's geared down
// so it actually takes 32 of those, 2048 steps, to go the full way around.
int numsteps = 32;

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 10, 11, 9);
int direction = 1;

void setup()

void loop()
    direction = -direction;

    myStepper.step(direction * stepsPerRevolution * numsteps);