Unit C - Actuators & Displays

15. Stepper Motors & Drivers

Produce repeatable incremental motion.

Estimated time 4 hours

Learning outcomes

  • Compare stepper and DC motor behavior
  • Identify unipolar and bipolar driver approaches
  • Use STEP/DIR signals
  • Set current limits and power safely

Parts and preparation

Uno and either 28BYJ-48 + ULN2003 or NEMA17 + A4988/DRV8825 with motor supply.

Before power: inspect wiring, confirm supply voltage and ensure all connected circuits share GND.

Stepper Motors & Drivers instructional connection diagram
Open the diagram for a larger view. Trace every connection before building.

Stepping motion

A driver energises motor phases in sequence. Each input step advances a defined angle. Position is open-loop unless an external sensor is added.

28BYJ-48 path

The geared unipolar motor and ULN2003 board are simple for beginners but slow. Pin order matters.

A4988 path

A bipolar driver accepts STEP and DIR, supports microstepping and regulates coil current. Set the current limit before operation and fit the recommended VMOT capacitor.

Torque and speed

Torque falls at high step rates. Starting too fast can cause missed steps. Acceleration is needed for demanding motion.

Wiring and safe build sequence

Breadboard wiring for lesson 15: Stepper Motors & Drivers
Breadboard layout for this lesson. Match colours and pins before powering the circuit. Click the image for a larger view.
  1. A4988 STEP -> D3 and DIR -> D4
  2. RESET and SLEEP held HIGH as module documentation specifies
  3. VMOT and GND -> motor supply with local capacitor
  4. Logic VDD -> 5 V, logic GND -> common GND
  5. Motor coils -> 1A/1B and 2A/2B
Power rule: switch off before moving wires. Arduino I/O pins are control signals; high-current loads require a driver and suitable external supply.
const byte stepPin = 3;
const byte dirPin = 4;

void moveSteps(long steps, bool clockwise) {
  digitalWrite(dirPin, clockwise ? HIGH : LOW);
  for (long i = 0; i < steps; i++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(800);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(800);
  }
}

void setup() {
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
}

void loop() {
  moveSteps(200, true);
  delay(500);
  moveSteps(200, false);
  delay(500);
}

How the code works

  1. One pulse advances one full step only when microstep pins select full-step mode.
  2. 200 steps is one revolution for a common 1.8-degree motor, not for every motor/gearbox.

Test and record evidence

Expected result: The motor moves a fixed distance in each direction.

Practical evidence checklist

Common faults and checks
  • Identify coil pairs with resistance/continuity measurements.
  • Jerking without rotation suggests wrong coil pairing.
  • Never plug/unplug a motor while the driver is powered.
Extension challenge: Add gradual acceleration by reducing the pulse delay over the first 50 steps.

Check your understanding

Q1. Why can a stepper lose position?

Show answer

Open-loop steps may be missed if load or speed exceeds available torque.

Q2. What must be set on an A4988?

Show answer

Its current limit, appropriate to the motor and module cooling.