Table of Contents
- What Is the A4988 Stepper Motor Driver?
- A4988 Pinout & Pin Functions
- Setting the Current Limit — Critical First Step
- Microstepping Modes Explained
- Wiring A4988 to Arduino & NEMA 17
- Arduino Code Examples
- Using the AccelStepper Library
- Heat Management & Decoupling Capacitors
- Troubleshooting Common Issues
- Frequently Asked Questions
The A4988 stepper motor driver from Allegro Microsystems is arguably the most widely used stepper driver in the hobby electronics and DIY CNC world. Found on virtually every 3D printer’s RAMPS 1.4 board and countless RepRap-style machines, the A4988 brings smooth microstepping and simple step/direction interface to any Arduino project. If you want to control a NEMA 17 stepper motor precisely, this is the driver to start with.
In this comprehensive guide, we’ll cover everything from understanding the A4988 pinout and setting the current limit correctly (arguably the most critical step that beginners skip), to writing your first Arduino sketch and using the AccelStepper library for advanced motion profiles.
What Is the A4988 Stepper Motor Driver?
The A4988 is a complete microstepping motor driver with a built-in translator for easy operation. Its “translator” means you don’t need to send complex multi-pin sequences to move the stepper — you simply send pulses on a single STEP pin, and the chip handles all the coil energisation sequences internally. This is a massive improvement over driving steppers manually through an L298N.
Key Features & Specifications
- Motor voltage (Vs): 8V to 35V
- Logic voltage: 3V to 5.5V (compatible with both Arduino Uno and 3.3V boards)
- Maximum continuous current: 1A per coil (2A peak with heatsink)
- Microstepping modes: Full, half, 1/4, 1/8, 1/16
- Simple step/direction interface — works with any microcontroller
- Adjustable current limiting via potentiometer
- Thermal shutdown, overcurrent, short-circuit protection
- Automatic current decay mode selection
A4988 vs L298N for Stepper Motors
The A4988 wins decisively for stepper motor control. The L298N is a general-purpose dual H-bridge limited to full-step mode, whereas the A4988 is purpose-built for steppers with microstepping support, current limiting, and a far simpler control interface. For any serious stepper project, the A4988 (or its sibling DRV8825) is the right choice.
A4988 Stepper Motor Driver Controller Board – RED
The genuine A4988 driver module with all breakout pins, onboard voltage regulators, and potentiometer for current adjustment — ready to pair with your NEMA 17.
A4988 Pinout & Pin Functions
The A4988 breakout module (the small purple or red PCB) exposes the following pins:
Motor Outputs
- 1A, 1B: Coil A connections (one terminal of first coil pair)
- 2A, 2B: Coil B connections (one terminal of second coil pair)
Power Supply Pins
- VMOT: Motor power supply (8V–35V). Always add a 100µF capacitor across VMOT and GND.
- GND (motor side): Motor supply ground.
- VDD: Logic power supply (3V–5.5V). Connect to Arduino’s 5V (or 3.3V for ESP32).
- GND (logic side): Logic ground. Connect to Arduino GND.
Control Pins
- STEP: Each LOW-to-HIGH transition advances the motor by one step (or microstep). This is the main pulse pin.
- DIR: Direction control. HIGH = clockwise, LOW = counterclockwise (or vice versa, depending on coil wiring).
- ENABLE (EN): Active LOW. When LOW (or floating — internal pull-down), the driver is enabled. Pull HIGH to disable and de-energise the motor coils (motor will freewheel).
- RESET: Active LOW. Pull LOW to reset the driver. Must be HIGH for normal operation. Often connected to SLEEP.
- SLEEP: Active LOW. Pull LOW to put driver in sleep mode (ultra-low power). Pull HIGH for normal operation. Often tied together with RESET.
Microstepping Pins
- MS1, MS2, MS3: Microstepping resolution selection. Logic level combinations set the stepping mode (see Microstepping section below).
Current Sense Pins
- RS1, RS2: Current sense resistors (used for current limiting). These connect to the module’s built-in sense resistors — you don’t need to do anything with these externally.
Setting the Current Limit — Critical First Step
This is the step most beginners skip, and it causes more A4988 deaths and burned stepper motors than anything else. Before powering your motor, you must set the current limit to match your stepper motor’s rated current.
Why Is Current Limiting Important?
Stepper motors are typically rated for a specific current per coil (e.g., 1.7A for a common NEMA 17). The A4988 will happily push more current than this if not limited, overheating both itself and the motor. Setting the current limit correctly also ensures optimal torque without excess heat.
How to Set the Current Limit
The A4988 module has a small potentiometer (a tiny adjustable screw). The current limit is set by adjusting the reference voltage (Vref) measured at the potentiometer wiper.
The formula is:
Vref = I_max × (8 × R_sense)
For most A4988 modules, R_sense = 0.1Ω, so:
Vref = I_max × 0.8
For a 1.7A motor: Vref = 1.7 × 0.8 = 1.36V
For a 1A motor: Vref = 1.0 × 0.8 = 0.8V
Step-by-Step Current Setting Procedure
- Power your circuit with logic power (5V from Arduino) but without motor power.
- Connect a multimeter (DC voltage mode) with the negative probe to GND and positive probe to the potentiometer wiper (the metal screw top).
- Rotate the potentiometer (usually with a small flathead screwdriver) until the multimeter reads your target Vref.
- Clockwise typically increases Vref (more current); counterclockwise decreases it.
- Start low (e.g., 0.5V) and increase gradually while observing motor and driver temperature.
Pro tip: For most hobbyist applications, setting the current to 70% of the motor’s rated current gives a good balance between torque, heat, and driver longevity. A 1.7A motor can be set to ~1.2A for safe 24/7 operation.
Microstepping Modes Explained
One of the A4988’s biggest advantages over simpler drivers is microstepping — the ability to position the stepper motor between full steps, resulting in smoother motion and finer resolution.
| MS1 | MS2 | MS3 | Step Mode | Steps/Rev (1.8° motor) |
|---|---|---|---|---|
| LOW | LOW | LOW | Full step | 200 |
| HIGH | LOW | LOW | Half step | 400 |
| LOW | HIGH | LOW | 1/4 step | 800 |
| HIGH | HIGH | LOW | 1/8 step | 1600 |
| HIGH | HIGH | HIGH | 1/16 step | 3200 |
For 3D printing and CNC, 1/16 microstepping (3200 steps/rev) is common as it produces very smooth motion. Note that microstepping reduces torque proportionally — at 1/16 step, you have roughly 1/16 the torque of full stepping. For positioning applications where you don’t need maximum torque, this is usually fine.
Wiring A4988 to Arduino & NEMA 17
Components Required
- Arduino Uno (or Nano)
- A4988 Stepper Driver Module
- NEMA 17 Stepper Motor (4-wire bipolar)
- 12V DC power supply (minimum 1A)
- 100µF electrolytic capacitor (CRITICAL — across VMOT and GND)
- Jumper wires
Wiring Table
| A4988 Pin | Connect To | Notes |
|---|---|---|
| VMOT | 12V supply positive | Add 100µF cap to GND! |
| GND (motor) | 12V supply negative + Arduino GND | Common ground |
| VDD | Arduino 5V | Logic supply |
| GND (logic) | Arduino GND | Logic ground |
| STEP | Arduino Pin 3 | Step pulse input |
| DIR | Arduino Pin 4 | Direction control |
| RESET | SLEEP pin (tie together) | Both pulled HIGH |
| SLEEP | Arduino 5V (via RESET) | Enable driver |
| MS1, MS2, MS3 | See microstepping table | All LOW = full step |
| 1A, 1B | NEMA 17 Coil A wires | Usually black + green |
| 2A, 2B | NEMA 17 Coil B wires | Usually red + blue |
Warning: Never connect or disconnect the stepper motor while the A4988 is powered! This can generate voltage spikes that will instantly destroy the driver chip. Always power down before changing motor connections.
NEMA 17 5.6 kg-cm Stepper Motor with Detachable Cable – D-Type Shaft
The ideal companion for the A4988 driver — this 1.2A NEMA 17 stepper is within the A4988’s current rating and provides excellent torque for 3D printers and CNC machines.
Arduino Code Examples
Basic Step/Direction Control
// A4988 Basic Step/Direction Control
const int STEP_PIN = 3;
const int DIR_PIN = 4;
void setup() {
pinMode(STEP_PIN, OUTPUT);
pinMode(DIR_PIN, OUTPUT);
}
void stepMotor(int steps, bool clockwise, int stepDelayUs) {
digitalWrite(DIR_PIN, clockwise ? HIGH : LOW);
for (int i = 0; i < steps; i++) {
digitalWrite(STEP_PIN, HIGH);
delayMicroseconds(stepDelayUs);
digitalWrite(STEP_PIN, LOW);
delayMicroseconds(stepDelayUs);
}
}
void loop() {
// Rotate 1 revolution CW (200 steps at full step)
stepMotor(200, true, 1000); // 1ms per step = ~100 RPM
delay(1000);
// Rotate 1 revolution CCW
stepMotor(200, false, 1000);
delay(1000);
}
1/16 Microstepping Example
// Wire MS1, MS2, MS3 all HIGH for 1/16 microstepping
// Or set them via Arduino pins:
const int MS1 = 5, MS2 = 6, MS3 = 7;
void setup() {
pinMode(STEP_PIN, OUTPUT);
pinMode(DIR_PIN, OUTPUT);
pinMode(MS1, OUTPUT);
pinMode(MS2, OUTPUT);
pinMode(MS3, OUTPUT);
// Set 1/16 microstepping
digitalWrite(MS1, HIGH);
digitalWrite(MS2, HIGH);
digitalWrite(MS3, HIGH);
}
void loop() {
// 1 revolution = 200 * 16 = 3200 microsteps
stepMotor(3200, true, 250); // Very smooth motion!
delay(1000);
stepMotor(3200, false, 250);
delay(1000);
}
Using the AccelStepper Library
For real-world projects, you need acceleration and deceleration to avoid motor stalling at high speeds. The AccelStepper library by Mike McCauley handles this beautifully and works perfectly with the A4988’s step/direction interface.
Install via Arduino IDE: Sketch → Include Library → Manage Libraries → search “AccelStepper” → Install.
#include <AccelStepper.h>
// DRIVER mode uses STEP and DIR pins only
AccelStepper stepper(AccelStepper::DRIVER, 3, 4); // STEP=3, DIR=4
void setup() {
stepper.setMaxSpeed(2000); // steps per second
stepper.setAcceleration(500); // steps per second per second
stepper.moveTo(3200); // Move 1 revolution (1/16 step)
}
void loop() {
if (stepper.distanceToGo() == 0) {
// Reverse direction when target reached
stepper.moveTo(-stepper.currentPosition());
}
stepper.run(); // Must be called frequently!
}
The key function is stepper.run() — it must be called as frequently as possible in your loop. Avoid using delay() anywhere in your main loop when using AccelStepper, as it will stutter the motion.
Heat Management & Decoupling Capacitors
The 100µF Capacitor — Not Optional
Stepper motors are inductive loads. When the driver switches coil current rapidly (especially in microstepping mode), voltage spikes can occur on the VMOT line. Without a bulk capacitor, these spikes can exceed the A4988’s absolute maximum voltage rating (35V) even from a 12V supply, instantly destroying the chip.
Place a 100µF electrolytic capacitor (rated ≥25V for a 12V supply) as close as possible to the VMOT and GND pins. This is non-negotiable.
Managing Driver Temperature
The A4988 includes thermal shutdown that activates around 150°C junction temperature. In practice, the driver should run warm but not hot-to-touch. If it shuts down frequently:
- Reduce the current limit (most common fix)
- Add a small heatsink to the A4988 chip
- Add a small 5V fan nearby if running continuously
- Ensure adequate PCB copper area around the driver
Troubleshooting Common Issues
Motor Not Moving / Stuttering
- Verify RESET and SLEEP pins are both HIGH.
- Check common ground between Arduino and A4988 logic GND.
- Current limit may be set too low — increase Vref slightly.
- Step pulse may be too fast — increase stepDelayUs to 1000 or higher.
Motor Vibrates but Doesn’t Rotate
- One coil pair is likely swapped — swap 1A and 1B (or 2A and 2B).
- Use a multimeter in continuity mode to identify which wire pairs belong to the same coil.
A4988 Gets Burning Hot Immediately
- Current limit is too high — turn the potentiometer counterclockwise.
- Check for short circuits in motor wiring.
Motor Loses Steps at High Speed
- Reduce speed (increase step delay).
- Increase current limit slightly (but stay within motor rating).
- Use acceleration/deceleration with AccelStepper instead of jumping to full speed instantly.
Driver Works Once, Then Never Again
- You disconnected the motor while powered — the resulting voltage spike destroyed the chip. This is the #1 killer of A4988 modules. Always power down before changing motor connections.
- Missing 100µF capacitor — voltage spikes killed the chip. Add the cap!
Frequently Asked Questions
What is the maximum RPM for NEMA 17 with A4988?
With a 12V supply and 1/16 microstepping, NEMA 17 motors typically achieve 200–400 RPM smoothly. Maximum RPM depends on supply voltage, motor inductance, and current limit. Higher voltage supplies (24V) allow faster speeds. At 24V, 600–1000 RPM is achievable with many NEMA 17 motors.
Can I use the A4988 with a 5V motor supply?
Technically yes (minimum VMOT is 8V per spec), but performance will be poor. The A4988 regulates current by rapidly switching (chopper drive), and low voltage supply limits this ability. Use at least 8V, ideally 12V or higher for good torque at speed.
What’s the difference between A4988 and DRV8825?
The DRV8825 supports up to 1/32 microstepping, handles up to 2.2A per coil, and works up to 45V — making it suitable for higher-current motors. The A4988 is limited to 1/16 microstepping and 2A peak. For 3D printers with standard NEMA 17 motors, both work well. For larger motors or smoother motion, prefer the DRV8825. We have a detailed comparison article for this exact question!
Can I use multiple A4988 drivers with one Arduino?
Yes! Each A4988 needs only two Arduino pins (STEP and DIR). An Arduino Uno can easily control 4–5 axes simultaneously by sharing RESET, SLEEP, and microstepping pins across all drivers.
Why is my NEMA 17 making a high-pitched whine?
This is the chopper frequency of the A4988 (typically 20kHz–40kHz, often at the edge of hearing for adults). It’s normal. Microstepping at 1/16 typically reduces audible noise compared to full stepping. If very loud, verify current limit isn’t set too high.
How do I identify the coil pairs of my stepper motor?
Use a multimeter in continuity/resistance mode. Touch probe pairs: wires in the same coil pair will show low resistance (2–10 Ω typically), while wires from different coils show open circuit (infinite resistance).
Conclusion
The A4988 stepper motor driver transforms complex stepper control into a simple two-pin (step and direction) interface. With proper current limiting, the right decoupling capacitor, and the AccelStepper library for smooth motion profiles, you can build precise, smooth-moving CNC machines, 3D printers, camera sliders, and more.
Remember the golden rules: always set your current limit before first power-on, never disconnect the motor while powered, and always use that 100µF capacitor. Follow these, and your A4988 will serve you well for countless projects.
Get Your A4988 Driver from Zbotic
Shop A4988 drivers, NEMA 17 stepper motors, and all accessories with fast delivery across India.
Add comment