/* Stepper Motor Control - one revolution This program drives a unipolar or bipolar stepper motor. The motor is attached to digital pins 8 - 11 of the Arduino. The motor should revolve one revolution in one direction, then one revolution in the other direction. Created 11 Mar. 2007 Modified 30 Nov. 2009 by Tom Igoe */ #include const int stepsPerRevolution = 4096; // change this to fit the number of steps per revolution for your motor const unsigned char phasesMatrix[8] = { 0b00010000, 0b00110000, 0b00100000, 0b01100000, 0b01000000, 0b11000000, 0b10000000, 0b10010000 }; //initialize the stepper library on pins 8 through 11, phasesMatrix, pin_count, phase_count: Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11, 0, (unsigned char*)phasesMatrix, 4, 8); void setup() { // set the speed at 17 rpm: myStepper.setSpeed(17); // Open serial communications and wait for port to open: Serial.begin(115200); // this check is only needed on the Leonardo: while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only } } void loop() { // step one revolution in one direction: Serial.println("clockwise"); myStepper.step(stepsPerRevolution); delay(500); // step one revolution in the other direction: Serial.println("counterclockwise"); myStepper.step(-stepsPerRevolution); delay(500); }