Stepper Motor

In this project, you'll learn how to control a stepper motor with the Arduino.

A stepper motor can turn complete circles in either directions in increments of one step at a time. A ULN2003 Darlington driver chip is needed to control the motor.
 
Parts needed:
  • Arduino
  • Stepper motor
  • ULN2003 Darlington driver IC
  • Wires
  • Breadboard
Stepper motor
1 Making the connections

The stepper motor has five connection wires: red, orange, yellow, pink and blue. These five wires are already connected to the ULN2003 Darlington driver chip.

From the ULN2003 Darlington driver chip, six connections are made to the Arduino:
  • Connect IN1 to pin 8 on the Arduino.
  • Connect IN2 to pin 9 on the Arduino.
  • Connect IN3 to pin 10 on the Arduino.
  • Connect IN4 to pin 11 on the Arduino.
  • Connect GND or - to GND on the Arduino.
  • Connect VCC or + to 5V on the Arduino.
Servo motor connections
2 Create a new BareMinimum program and type in this code.
void motor(int orange, int yellow, int pink, int blue) {
  // each call will rotate the motor one step
  digitalWrite(8, orange);
  digitalWrite(9, yellow);
  digitalWrite(10, pink);
  digitalWrite(11, blue);
  delay(2);  
}

void setup() {
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
}

void loop() {
  for(int i=0; i<512; i++){  // clockwise
    motor(1,1,0,0);
    motor(0,1,1,0);
    motor(0,0,1,1);
    motor(1,0,0,1);
  }
  delay(1000);
  for(int i=0; i<512; i++){  // counter clockwise
    motor(1,0,0,1);
    motor(0,0,1,1);
    motor(0,1,1,0);
    motor(1,1,0,0);
  }
  delay(1000);
}
3 Run the program and you should see the stepper motor turning clockwise and counter clockwise.