In this lesson we will drive a stepper motor, the 28BYJ-48 using the ULN2003 driver board that is usually provided with them.

This stepper is small but remarkably strong. Originally they were used in applications such as air conditioning/HVAC, but hobbyists discovered how cheap and plentiful they were, so they became an Arduino fan favourite, and are often now included in kits.
They are 5v DC, the boards accept 5-12v, but each motor can draw up to 320mA, we will use external power attached to the 5-12v in, and ground attached to our battery pack and our Arduino.
To control the motor the stepper attaches to the driver board with 4 data lines and power. Our Arduino connects to IN1-IN4.

Code
We will use the default Arduino library to drive our steppers for now.
/*
Simply use the built-in library
to drive a stepper back and forth
*/
//Arduino stepper library
#include <Stepper.h>
// steps for one full turn of the output shaft:
// 32 steps inside the motor x about 64:1 gearing
#define STEPS 2048
// connections need to be done carefully
// In1-In4 are added in the sequence 1-3-2-4
Stepper stepper(STEPS, 3, 5, 4, 6);
// the number of steps to take
int numSteps;
// No setup here
void setup() {}
// loop runs constantly
void loop() {
// we are going to do a full revolution
// (the real gear ratio is 63.68:1, so it is a hair over)
numSteps = STEPS;
// speed in RPM; these little motors top out
// around 10 to 15 RPM
stepper.setSpeed(10);
// take the steps
stepper.step(numSteps);
// pause
delay(500);
// now backwards
stepper.step(-numSteps);
// pause
delay(500);
}


