The NEMA 17 stepper motor paired with an A4988 driver is one of the most popular combinations for Arduino-based motion control projects. It is the core of every desktop 3D printer, small CNC router, and laser engraver. If you are working on a stepper motor Arduino project — whether it is a camera slider, pick and place machine, or automated turntable — this guide walks you through everything: specs, wiring, current limiting, microstepping, and working code using the AccelStepper library. We will also cover the DRV8825 as a higher-current alternative to the A4988.
Table of Contents
NEMA 17 Stepper Motor Specifications
NEMA 17 refers to a standardised frame size — the faceplate measures 42.3mm x 42.3mm with a 31mm bolt hole spacing. It is a two-phase bipolar stepper motor, meaning it has two independent coil pairs (4 wires). The most common NEMA 17 variant used in 3D printers and DIY CNC has these specifications:
| Parameter | Typical Value |
|---|---|
| Step angle | 1.8° (200 steps/revolution) |
| Holding torque | 40–60 N.cm (400–600 mN.m) |
| Rated current | 1.2A–2A per coil |
| Coil resistance | 1.5–3.5 ohm per coil |
| Inductance | 2–4 mH per coil |
| Shaft diameter | 5mm |
| Body length | 34mm, 40mm, 47mm (varies by model) |
| Wires | 4 wires (two coil pairs: 1A/2A and 1B/2B) |
The 4-wire colour code varies by manufacturer, but typically: black and green are one coil (A), red and blue are the other coil (B). You can confirm coil pairs with a multimeter — wires from the same coil will show resistance of 2–4 ohms between them; wires from different coils will show no continuity.
A4988 Stepper Driver Module Explained
The A4988 is a microstepping bipolar stepper motor driver IC from Allegro MicroSystems, typically sold as a small module (15mm x 20mm) with onboard current sensing resistors and a potentiometer for current limiting. It is the standard driver on most RAMPS 1.4 and 3D printer boards.
A4988 key specifications:
- Supply voltage: 8V to 35V motor supply (VMOT), 3–5.5V logic supply (VDD)
- Output current: 1A per coil continuous, 2A peak (with heatsink and adequate cooling)
- Microstepping: Full, 1/2, 1/4, 1/8, 1/16 step via MS1/MS2/MS3 pins
- Control interface: STEP and DIR digital inputs — one pulse on STEP = one step
- Built-in over-current protection, over-temperature shutdown, and under-voltage lockout
- Adjustable current via onboard trim potentiometer
The A4988 module has a simple interface: pull DIR high for clockwise rotation, low for counter-clockwise. Toggle the STEP pin once per desired step. Speed is determined entirely by how fast you toggle STEP — no PWM, no complex signals.
Current Limiting Adjustment
Setting the correct motor current on the A4988 is critical. Too low and the motor loses torque and misses steps. Too high and the driver and motor both overheat and can be damaged. The formula uses the voltage at the VREF test point:
Current limit = VREF / (8 x Rsense)
For most A4988 modules, Rsense = 0.1 ohm (100 milliohm):
Current limit (A) = VREF (Volts) / 0.8
Example: For NEMA 17 rated at 1.2A per coil:
VREF = 1.2 x 0.8 = 0.96V
To set this:
1. Power the Arduino and A4988 (logic power only, no motor)
2. Place multimeter black lead on GND
3. Place red lead on the centre of the potentiometer (VREF test point)
4. Slowly turn the potentiometer until you read 0.96V
5. Start at 70% of rated current and increase if needed
A small self-adhesive heatsink on the A4988 IC is strongly recommended for sustained operation. The motor will also get warm — this is normal, but it should not burn your fingers. If it does, reduce current by 10–20%.
Microstepping Modes
The A4988 supports five resolution modes set by the MS1, MS2, MS3 pins. Microstepping divides each full step into smaller sub-steps by partially energising both coils simultaneously, resulting in smoother motion and quieter operation.
| MS1 | MS2 | MS3 | Mode | Steps/Rev | Resolution |
|---|---|---|---|---|---|
| LOW | LOW | LOW | Full step | 200 | 1.8° |
| HIGH | LOW | LOW | Half step | 400 | 0.9° |
| LOW | HIGH | LOW | Quarter step | 800 | 0.45° |
| HIGH | HIGH | LOW | Eighth step | 1600 | 0.225° |
| HIGH | HIGH | HIGH | Sixteenth step | 3200 | 0.1125° |
Note: at higher microstepping modes, available torque is reduced. Use 1/8 or 1/16 stepping for smooth motion at low loads; use full or half stepping for maximum torque.
Wiring Diagram: Arduino + A4988 + NEMA 17
You need three power/signal connections: Arduino (5V logic), an external motor supply (12V recommended), and the motor. The Arduino and external supply must share a common GND.
A4988 Module Connection
VDD --> Arduino 5V
GND (logic) --> Arduino GND
VMOT --> 12V external power supply +
GND (motor) --> 12V external power supply - AND Arduino GND
STEP --> Arduino Pin 3
DIR --> Arduino Pin 2
SLEEP --> Arduino 5V (tie HIGH to enable)
RESET --> Arduino 5V (tie HIGH to enable, or connect to SLEEP)
MS1 --> Connect to 5V for 1/8 step (or leave floating for full step)
MS2 --> Connect to 5V for 1/8 step
MS3 --> Leave floating for 1/8 step (all three LOW = full step)
ENABLE --> Leave floating (internally pulled LOW = enabled)
A4988 Motor Output Pins --> NEMA 17
1A, 2A --> Coil A (e.g., black and green wires)
1B, 2B --> Coil B (e.g., red and blue wires)
CRITICAL: Add a 100uF electrolytic capacitor between VMOT and GND
near the A4988. This absorbs voltage spikes from motor back-EMF
that can destroy the driver IC without the capacitor.
Basic Arduino Code (Step/Direction)
// Basic NEMA 17 + A4988 control (no library needed)
const int stepPin = 3;
const int dirPin = 2;
// For 1/8 microstepping: 200 steps x 8 = 1600 steps/revolution
const int stepsPerRev = 1600;
void setup() {
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
}
void stepMotor(int steps, int speedRPM) {
// Calculate delay between steps for target RPM
long delayMicros = (60L * 1000000L) / ((long)stepsPerRev * speedRPM);
for (int i = 0; i < abs(steps); i++) {
digitalWrite(stepPin, HIGH);
delayMicroseconds(delayMicros / 2);
digitalWrite(stepPin, LOW);
delayMicroseconds(delayMicros / 2);
}
}
void loop() {
digitalWrite(dirPin, HIGH); // Clockwise
stepMotor(stepsPerRev, 60); // One full revolution at 60 RPM
delay(500);
digitalWrite(dirPin, LOW); // Counter-clockwise
stepMotor(stepsPerRev, 60); // One full revolution
delay(500);
}
AccelStepper Library: Smooth Acceleration and Deceleration
The Arduino built-in Stepper library uses constant speed and blocks your program during movement. The AccelStepper library runs non-blocking and adds acceleration and deceleration — essential for preventing missed steps at high speeds and for smooth motion in camera sliders and robotic arms.
Install AccelStepper from the Arduino IDE Library Manager (search “AccelStepper” by Mike McCauley).
#include <AccelStepper.h>
// AccelStepper with STEP/DIR interface (type = DRIVER)
// DRIVER = 1, stepPin, dirPin
AccelStepper stepper(AccelStepper::DRIVER, 3, 2);
const int stepsPerRev = 1600; // 200 steps x 8 microsteps
void setup() {
stepper.setMaxSpeed(3200); // Max steps per second
stepper.setAcceleration(800); // Steps per second^2
stepper.setCurrentPosition(0); // Home position
Serial.begin(9600);
}
void loop() {
// Move to absolute position (3 revolutions clockwise)
stepper.moveTo(stepsPerRev * 3);
while (stepper.distanceToGo() != 0) {
stepper.run(); // Must be called frequently in loop
}
Serial.println("Reached 3 revolutions");
delay(1000);
// Return to home
stepper.moveTo(0);
while (stepper.distanceToGo() != 0) {
stepper.run();
}
Serial.println("Back to home");
delay(1000);
// Relative move (half revolution backward)
stepper.move(-stepsPerRev / 2);
while (stepper.distanceToGo() != 0) {
stepper.run();
}
delay(500);
}
Key AccelStepper functions:
setMaxSpeed(steps/sec)— maximum speed in steps per secondsetAcceleration(steps/sec^2)— acceleration and deceleration ratemoveTo(absolutePosition)— move to an absolute step positionmove(relativeSteps)— move a relative number of steps from current positionrun()— must be called repeatedly in loop; executes one step when duerunToPosition()— blocking version that waits until target is reachedcurrentPosition()— returns current step count
DRV8825 as an Alternative
The DRV8825 from Texas Instruments is a direct pin-compatible upgrade to the A4988. It supports higher current (1.5A per coil continuous, 2.5A peak) and finer microstepping (up to 1/32 step). The current limit formula changes:
DRV8825 Current Limit:
VREF = Current limit (A) / 2
Example: For 1.2A per coil:
VREF = 1.2 / 2 = 0.6V
DRV8825 also needs a minimum of 1 microsecond HIGH pulse on STEP pin
(A4988 only needs 1 microsecond). For compatibility, increase step pulse
in code if switching from A4988 to DRV8825:
delayMicroseconds(2); // After setting STEP HIGH, before LOW
The DRV8825 module is physically identical to A4988 but is usually blue instead of red. Both modules use the same STEP/DIR/ENABLE/MS1/MS2/MS3 pinout and can be swapped with only the VREF adjustment and the 1 microsecond step delay change needed.
Modern alternatives include the TMC2209 driver which adds UART-configurable current, StealthChop (ultra-quiet) mode, and SpreadCycle (high-speed) mode. Used in most modern 3D printers (Ender 3 V2, Prusa i3 MK3S). For quiet operation on camera sliders or home automation, the TMC2209 is worth the higher price.
Common Issues and Solutions
- Motor vibrates but does not rotate: Coil wiring is incorrect. The two wires connected to 1A/2A must be from the same coil, and the two wires connected to 1B/2B must be from the other coil. Use a multimeter to confirm continuity between coil pair wires.
- Motor misses steps at higher speeds: Acceleration is too fast for the load — use AccelStepper with a lower acceleration value. Alternatively, current limit may be too low — increase VREF slightly. Also ensure the motor supply voltage is 12V (not 5V — higher voltage enables faster current rise through coil inductance).
- A4988 driver gets very hot or burns out: VREF is set too high, or there is no decoupling capacitor on VMOT. Add a 100uF capacitor between VMOT and GND right at the driver module. Never disconnect the motor while the driver is powered — the back-EMF spike exceeds 35V and destroys the A4988.
- Motor runs rough or makes excessive noise: Enable microstepping (MS1/MS2/MS3 pins). At 1/8 or 1/16 step mode, motion is dramatically smoother. Also ensure the motor current is set correctly — too low causes rough detent-to-detent stepping sound.
- Motor moves in wrong direction: Swap either the two 1A/2A wires OR the two 1B/2B wires, OR pull DIR pin to the opposite logic level in your code.
Project Applications
- 3D printing: The NEMA 17 + A4988/TMC2209 is the standard for all Cartesian and CoreXY 3D printers. X, Y, Z axes and extruder each use one motor-driver pair.
- CNC routers: NEMA 17 or NEMA 23 steppers driven by DRV8825 or TB6600 drivers on GRBL-based controllers.
- Camera and telescope sliders: Smooth linear motion using NEMA 17 + lead screw or timing belt. AccelStepper’s acceleration curves give the smooth start/stop needed for timelapse photography.
- Automated plant watering: NEMA 17 driving a peristaltic pump or valve for precise liquid dispensing volumes.
- Turntables for product photography: 360° rotation control for photographing products from all angles.
- Laser engravers: NEMA 17 on both X and Y axes controlled by GRBL firmware for 2D vector cutting and engraving.
Frequently Asked Questions
Q: What power supply should I use with NEMA 17 and A4988?
Use a 12V DC power supply with at least 2A current capacity (for a single motor, 2A is sufficient; for multi-axis CNC, use 5–10A depending on the number of motors). The 12V supply enables faster current rise through the coil inductance, improving high-speed performance significantly compared to a 5V supply. The A4988 works down to 8V but 12V is recommended for NEMA 17.
Q: Do I need a heatsink on the A4988?
Yes, for any sustained use above 0.8A per coil. The A4988 IC’s maximum junction temperature is 150°C, and without a heatsink it reaches thermal shutdown quickly at 1A+. Apply the small self-adhesive aluminium heatsink included with most modules. For 3D printers running continuously, also ensure your electronics enclosure has some airflow.
Q: What is the difference between A4988 and DRV8825?
The DRV8825 supports up to 1/32 microstepping (vs A4988’s 1/16), 1.5A continuous per coil (vs A4988’s 1A), and operates at up to 45V (vs A4988’s 35V). The pinout is identical, so they are drop-in replacements on the same board. The DRV8825 requires at minimum a 2-microsecond STEP pulse HIGH width, while A4988 only requires 1 microsecond — adjust your step delay if swapping.
Q: Can I run two NEMA 17 motors from one Arduino?
Yes. Use one A4988 module per motor (each motor needs its own driver). All modules share the same motor power supply and Arduino GND. You can use different STEP/DIR pins for each driver, or share DIR if both motors should move in the same direction. Multi-motor AccelStepper objects can be managed simultaneously for coordinated motion.
Q: Why must I never disconnect the motor while the A4988 is powered?
Disconnecting a motor while the driver is active causes the motor’s coil inductance to generate a large voltage spike (potentially 50–100V) in the opposite direction of current flow. This spike exceeds the A4988’s absolute maximum voltage (35V) and destroys the driver IC instantly. Always power off the electronics before disconnecting motor wires.
Shop Stepper Motors at Zbotic.in
NEMA 17 motors, A4988 drivers, DRV8825, heatsinks — everything for your CNC or 3D printer build with fast delivery across India.
Add comment