The A4988 drives the NEMA 17 steppers used in 3D printers, CNC machines and camera sliders. The Nano only sends two signals: a pulse on STEP for each step and a level on DIR for the direction.
The motor runs from its own 12 V supply on VMOT, while the A4988’s logic runs from the Nano’s 5V. Set the current limit with the trimmer first — it is the one step that decides whether the driver survives.
Wiring
| Arduino Nano | A4988 stepper motor driver | Wire | Notes |
|---|---|---|---|
| — | 1A | — | To Motor coil A, wire 1 (not drawn) |
| — | 1B | — | To Motor coil A, wire 2 (not drawn) |
| — | 2A | — | To Motor coil B, wire 1 (not drawn) |
| — | 2B | — | To Motor coil B, wire 2 (not drawn) |
| D3 | STEP | yellow | |
| D2 | DIR | green | |
| D4 | EN | orange | LOW = driver on. Leave it unconnected if you never need to free the motor. |
| 5V | SLP | red | SLP and RST must be HIGH, or the driver sleeps. Many people bridge SLP to RST instead. |
| 5V | RST | red | |
| 5V | VDD | red | |
| GND | GND | black | Logic and motor grounds meet here. |
| 12 V 2 A adapter · + | VMOT | red | 100 µF electrolytic across VMOT/GND, right at the driver. |
| 12 V 2 A adapter · - | GND | black |
Motor 8–35 V on VMOT; logic 3–5.5 V on VDD part, 5 V board. Logic levels follow VDD. Power VDD from 3.3 V on ESP32 and Pico and from 5 V on Uno, and STEP/DIR/EN connect directly. The motor supply on VMOT is separate.
Board quirks
- Set the current limit before connecting the motor: turn the small pot until Vref (pot wiper to GND) = motor current × 8 × Rsense. With 0.1 Ω sense resistors and a 1 A motor, Vref ≈ 0.8 V; with 0.05 Ω (some clones), 0.4 V.
- Never unplug the motor while VMOT is powered — the voltage spike kills the A4988.
- MS1–MS3 left open = full steps (200 per turn). Tie all three to 5V for 1/16 microsteps (3200 per turn) and raise the speeds.
- Find the coil pairs with a multimeter: two wires with a few ohms between them are one coil (1A/1B).
- The Nano’s STEP pulses are fast enough for ~4000 steps/s with AccelStepper; beyond that use a timer-based library.
Code
// A4988 stepper driver on an Arduino Nano with AccelStepper: one revolution each way.
// STEP → D3, DIR → D2, EN → D4 (LOW = enabled), SLP and RST → 5V, VDD → 5V, GND → GND,
// VMOT → 12 V supply (+), supply (−) → GND. MS1-MS3 open = full steps (200/rev for a NEMA 17).
#include <AccelStepper.h>
const uint8_t STEP_PIN = 3;
const uint8_t DIR_PIN = 2;
const uint8_t EN_PIN = 4;
const long STEPS_PER_REV = 200;
AccelStepper stepper(AccelStepper::DRIVER, STEP_PIN, DIR_PIN);
void setup() {
Serial.begin(115200);
stepper.setEnablePin(EN_PIN);
stepper.setPinsInverted(false, false, true); // EN is active-LOW on the A4988
stepper.enableOutputs();
stepper.setMaxSpeed(400); // steps/s
stepper.setAcceleration(800);
stepper.moveTo(STEPS_PER_REV);
Serial.println(F("Driver enabled - one turn forward"));
}
void loop() {
if (stepper.distanceToGo() == 0) {
Serial.print(F("At step "));
Serial.println(stepper.currentPosition());
delay(500);
stepper.moveTo(-stepper.currentPosition());
}
stepper.run();
}// A4988 stepper driver on an Arduino Nano with AccelStepper: one revolution each way.
// STEP → D3, DIR → D2, EN → D4 (LOW = enabled), SLP and RST → 5V, VDD → 5V, GND → GND,
// VMOT → 12 V supply (+), supply (−) → GND. MS1-MS3 open = full steps (200/rev for a NEMA 17).
#include <AccelStepper.h>
const uint8_t STEP_PIN = 3;
const uint8_t DIR_PIN = 2;
const uint8_t EN_PIN = 4;
const long STEPS_PER_REV = 200;
AccelStepper stepper(AccelStepper::DRIVER, STEP_PIN, DIR_PIN);
void setup() {
Serial.begin(115200);
stepper.setEnablePin(EN_PIN);
stepper.setPinsInverted(false, false, true); // EN is active-LOW on the A4988
stepper.enableOutputs();
stepper.setMaxSpeed(400); // steps/s
stepper.setAcceleration(800);
stepper.moveTo(STEPS_PER_REV);
Serial.println(F("Driver enabled - one turn forward"));
}
void loop() {
if (stepper.distanceToGo() == 0) {
Serial.print(F("At step "));
Serial.println(stepper.currentPosition());
delay(500);
stepper.moveTo(-stepper.currentPosition());
}
stepper.run();
}Library: AccelStepper (Mike McCauley) — compiled with AccelStepper 1.64.
Expected serial output
Driver enabled - one turn forward
At step 200
At step -200
At step 200Driver enabled - one turn forward At step 200 At step -200 At step 200
Common errors
Motor buzzes or jerks back and forth
One coil pair split across 1A/2A, or the current limit set too low. Recheck pairs with a meter.
Driver gets very hot
Current limit too high or no heatsink. Reduce Vref; above ~1 A per coil add the stick-on heatsink.
Nothing moves, no holding torque
SLP or RST floating, EN high, or no VMOT. Check all three.