Preview build — page text is a draft awaiting human review. Code badges come from real compiles. The flasher is real but not yet hardware-tested; the Playground is still a preview.

A4988 stepper driver with Arduino Nano — NEMA 17 on STEP/DIR

Wire an A4988 driver to an Arduino Nano (STEP D3, DIR D2, EN D4) with a 12 V motor supply, set the current limit and turn a NEMA 17 with AccelStepper.

Arduino C++Verified — core avr 1.8.8, AccelStepper 1.64, 3 Nov 2026Compile-only

Community draft — report a mistake

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 NanoOnly the pins used are shown · 5 V logic12 V 2 A adapterA4988 stepper motor driver+-5VGNDD4D3D2ENMS1 (not connected)MS2 (not connected)MS3 (not connected)RSTSLPSTEPDIRVMOTGND2B → Motor coil B, wire 22A → Motor coil B, wire 11A → Motor coil A, wire 11B → Motor coil A, wire 2VDD
Also needed: 100 µF / 25 V electrolytic capacitor, NEMA 17 bipolar stepper motor.
Every connection
Arduino NanoA4988 stepper motor driverWireNotes
—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)
D3STEPyellow
D2DIRgreen
D4ENorangeLOW = driver on. Leave it unconnected if you never need to free the motor.
5VSLPredSLP and RST must be HIGH, or the driver sleeps. Many people bridge SLP to RST instead.
5VRSTred
5VVDDred
GNDGNDblackLogic and motor grounds meet here.
12 V 2 A adapter · +VMOTred100 µF electrolytic across VMOT/GND, right at the driver.
12 V 2 A adapter · -GNDblack

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-nano.inoArduino C++Open in PlaygroundOpen in PlaygroundFlash
// 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

Serial Monitor · 115200Output
Driver 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.

↑↓ to move · Enter to open