Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Motors & Actuators

How to Use Stepper Motor with Arduino: NEMA 17 + A4988 Guide

How to Use Stepper Motor with Arduino: NEMA 17 + A4988 Guide

March 11, 2026 /Posted byJayesh Jain / 0

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
  • A4988 Driver Module Explained
  • Current Limiting Adjustment
  • Microstepping Modes
  • Wiring Diagram: Arduino + A4988 + NEMA 17
  • Basic Arduino Code
  • AccelStepper Library
  • DRV8825 as Alternative
  • Common Issues and Fixes
  • Project Applications
  • FAQ

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.

Recommended: NEMA 17 3D Printer 2-Phase 4-Wire Stepper Motor (17HD34008-22B) — Standard NEMA 17 with 1.8° step angle, 4 wires, 5mm shaft. Direct replacement for most 3D printers and compatible with all common stepper drivers including A4988 and DRV8825.

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.

Recommended: A4988 Stepper Motor Driver Controller Board (Red) — The standard A4988 module in red PCB with onboard current limit potentiometer. Supports up to 1/16 microstepping and 1A continuous per coil. Includes heat dissipation pads.

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%.

Recommended: Aluminum Heatsink for A4988 / DRV8825 Stepper Driver (Pack of 5) — Self-adhesive aluminium heatsinks sized for A4988 and DRV8825 modules. Essential for sustained operation above 0.8A per coil. Pack of 5 for multi-axis CNC and 3D printer builds.

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 second
  • setAcceleration(steps/sec^2) — acceleration and deceleration rate
  • moveTo(absolutePosition) — move to an absolute step position
  • move(relativeSteps) — move a relative number of steps from current position
  • run() — must be called repeatedly in loop; executes one step when due
  • runToPosition() — blocking version that waits until target is reached
  • currentPosition() — 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.

Browse Motors

Tags: A4988, Arduino, CNC, DRV8825, NEMA 17, stepper motor
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
PCB Design Basics: From Protot...
blog pcb design basics from prototype to production 594596
blog battery management system bms explained 594602
Battery Management System (BMS...

Related posts

Svg%3E
Read more

Gear Motor Guide: N20, JGB37, and Planetary Motors Compared

April 1, 2026 0
When your project needs more torque than a bare DC motor can provide, a gear motor is the answer. By... Continue reading
Svg%3E
Read more

Miniature Pump Hydroponics: Automated Nutrient Dosing System

April 1, 2026 0
Hydroponics grows plants in nutrient-rich water instead of soil, and automating the nutrient dosing process with peristaltic pumps and Arduino... Continue reading
Svg%3E
Read more

Drone Motor Testing: Thrust Stand Build and KV Measurement

April 1, 2026 0
If you are building a drone, selecting the right motor-propeller combination is critical for flight performance. A drone motor thrust... Continue reading
Svg%3E
Read more

Pump Selection Guide: Peristaltic, Submersible, and Diaphragm

April 1, 2026 0
When your Arduino project needs to move liquid — whether for automated plant watering, hydroponics, aquarium management, or a coffee... Continue reading
Svg%3E
Read more

Solenoid Guide: Door Locks, Valves, and Automation Projects

April 1, 2026 0
A solenoid is an electromechanical device that converts electrical energy into linear motion. When you energise the coil, a plunger... Continue reading

Add comment Cancel reply

Your email address will not be published. Required fields are marked

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now