All articles

    The A4988 Stepper Driver: Wiring and Setting the Current Correctly

    The A4988 stepper motor driver explained: the STEP and DIR pins, the code and calculating speed in RPM, microstepping, setting the current limit with Vref with a worked example, the supply capacitor and motor voltage, the ENABLE pin, cooling, the mistakes that burn out the driver, a fault table, and the DRV8825 and TMC2208 alternatives.

    Updated 5 min read

    A stepper motor moves in counted steps, which is why it's the heart of 3D printers and CNC machines. An Arduino can't drive it directly; it needs a driver. The best known is the A4988: cheap, and controlled with just two pins.

    Each pulse on the STEP pin moves the motor one step
    Each pulse on the STEP pin moves the motor one step

    If you don't know the difference between a stepper and a servo, start with servos and steppers.

    Wiring

    PinConnection
    VMOT and GNDThe motor supply (8–35 V) + a 100 µF capacitor close by
    VDD and GND3.3 or 5 V from the Arduino
    1A and 1BThe motor's first coil
    2A and 2BThe second coil
    STEPA pin from the Arduino
    DIRA pin from the Arduino
    RESET and SLEEPConnected together (or to HIGH)
    ENABLEGround or a pin (LOW = enabled)
    MS1–MS3For microstepping

    How do you identify each coil's wires? Measure with a multimeter: the two wires with a resistance between them (a few ohms) are the same coil.

    And if you have several motors, a CNC shield for the Arduino Uno holds 4 drivers and has jumper positions for microstepping, which is far more convenient than a breadboard.

    The code

    const int STEP = 3, DIR = 4;
    
    void setup() {
      pinMode(STEP, OUTPUT);
      pinMode(DIR, OUTPUT);
    }
    
    void loop() {
      digitalWrite(DIR, HIGH);
      for (int i = 0; i < 200; i++) {  // 200 steps = one revolution for a 1.8° motor
        digitalWrite(STEP, HIGH); delayMicroseconds(800);
        digitalWrite(STEP, LOW);  delayMicroseconds(800);
      }
      delay(1000);
    }

    For acceleration and higher speeds, use the AccelStepper library.

    Speed in numbers

    Each step in this code = 800 + 800 = 1.6 ms, so 625 steps per second.

    RPM = steps per second × 60 ÷ (200 × microstepping)

    In full steps: 625 × 60 ÷ 200 = 187.5 RPM. And at 1/16 with the same code: only about 11.7. So with microstepping the pulses must be much faster for the same speed.

    Microstepping

    MS1MS2MS3Step
    LLLFull
    HLL1/2
    LHL1/4
    HHL1/8
    HHH1/16

    A smaller step = smoother movement and quieter sound, but you need more pulses for the same revolution.

    Setting the current: the most important step

    The driver has a small potentiometer that sets the maximum coil current. Leave it at random and the motor will be weak, or it and the driver will overheat.

    I_max = Vref ÷ (8 × Rcs)
    • Rcs: the sense resistors on the driver (read their marking: R068 = 0.068, R100 = 0.1, R050 = 0.05).
    • With 0.068 Ω: I_max ≈ Vref × 1.84.
    • Set it to about 70% of the motor's rated current.

    Measuring: power VDD, measure the voltage between the potentiometer's wiper and ground with the multimeter, and turn it with a plastic screwdriver.

    A worked example

    A NEMA 17 motor rated 1.5 A per coil, and the driver has R068:

    1. The current needed = 70% × 1.5 = 1.05 A.
    2. Vref = 1.05 ÷ 1.84 ≈ 0.57 V.
    3. If the resistors are R100: I = Vref × 1.25, so Vref = 1.05 ÷ 1.25 ≈ 0.84 V.

    Or calculate it directly with the Vref calculator.

    The motor voltage

    A motor rated 3 V and you're feeding it 12 or 24? That's normal and intended. The driver limits the current, and a higher voltage makes the current reach the coil faster, so the motor can spin faster without losing torque. That's why printers run on 12 or 24 V. But don't exceed the driver's maximum voltage (35 V for the A4988), and leave a margin.

    The ENABLE pin

    • LOW: the driver is on and the motor holds its position.
    • HIGH: the coils are switched off, and the motor turns easily by hand and cools down.

    If the motor stands still for long periods and doesn't need to hold a load, set ENABLE = HIGH while it's stopped, saving power and heat. But it loses its position if it moves, so home it again.

    Mistakes that burn out the driver

    1. Disconnecting or connecting the motor with the power on. That's the most common cause of a burnt driver.
    2. No capacitor on VMOT. The high voltage spikes exceed its limit.
    3. High current without cooling: without a heatsink and fan, don't go above about 1 A.
    4. Fitting it backwards in the shield.

    Common faults

    FaultUsual cause
    The motor shudders but doesn't turnTwo wires from different coils swapped, or high speed without acceleration
    It turns the wrong wayInvert DIR in the code, or reverse one coil's wires
    It loses stepsCurrent too low, a heavy load, or a sudden high speed
    The driver is hot and cuts outHigh current without cooling
    Loud whiningFull steps; try 1/8 or 1/16
    No movement at allRESET and SLEEP not connected, or ENABLE is HIGH

    Alternatives

    • DRV8825: up to 1/32 steps and higher current, and its formula is I_max = Vref × 2 on most modules.
    • TMC2208 and TMC2209: very quiet, and popular in 3D printers.

    FAQ

    The motor is hot while stopped; is that normal? Yes, up to about 50–60 °C. If you can't hold it in your hand, lower Vref.

    Can I drive two motors from one driver? In parallel it's possible if the total current is within the limit, and both will move exactly together (like the Z axis on some printers). But one driver per motor is better.

    Circuits Nerd
    © 2026 Circuits Nerd. All rights reserved.