Here’s the no-nonsense guide to wiring a [stepper motor](https://www.onzuu.com/category/stepper-motors) to an [Arduino](https://www.ampheo.com/c/development-board-arduino)—covering the three most common setups.

**0) Know your parts**
* Motor type
* Bipolar (most NEMA-17): 4 wires (two coils).
* Unipolar (e.g., 28BYJ-48): 5 wires + [ULN2003](https://www.onzuu.com/search/ULN2003) driver board.
* Do NOT power the motor from the Arduino 5V pin. Use a separate supply sized for the motor current.
* Always share ground between the motor power supply, driver, and Arduino.
How to find the two coils (bipolar): with a multimeter, the two wires that show continuity belong to one coil (A+ A−), the other pair is the second coil (B+ B−).
**A) Bipolar stepper + A4988 (or [DRV8825](https://www.onzuu.com/search/DRV8825)) — most common (NEMA-17)**
**1) Wiring**
**Power**
* VMOT → motor supply (e.g., 12 V)
* GND (VMOT side) → motor supply ground
* VDD → Arduino 5V
* GND (logic side) → Arduino GND (tie both grounds together!)
**Control pins**
* STEP → any Arduino digital pin (e.g., D3)
* DIR → any Arduino digital pin (e.g., D4)
* ENABLE (optional) → Arduino pin (LOW = enable). If unused, tie to GND (enabled).
**Microstepping (optional)**
* MS1, MS2, MS3 → set HIGH/LOW for 1/2/4/8/16 (A4988) or up to 1/32 (DRV8825).
**Motor coils**
* 1A/1B → Coil A (A+, A−)
* 2A/2B → Coil B (B+, B−)
(It’ll spin the wrong way if swapped—just flip DIR in code or swap a coil pair.)
**Decoupling**
* Put a 100 µF electrolytic across VMOT–GND near the driver. It matters.
**2) Set the current limit (protects the motor & driver)**
* Power the board (VMOT + logic), don’t connect the motor yet.
* Measure Vref on the driver trimpot to GND.

(Typical R_sense = 0.05–0.1 Ω; check your module.)
* Set 𝐼𝑚𝑎𝑥≈ motor rated phase current (or a bit lower), then connect the motor.
**3) Minimal Arduino code (step/dir)**
```
const int PIN_STEP = 3;
const int PIN_DIR = 4;
void setup() {
pinMode(PIN_STEP, OUTPUT);
pinMode(PIN_DIR, OUTPUT);
digitalWrite(PIN_DIR, HIGH); // direction
}
void loop() {
// 200 pulses = one rev at full step for a 1.8° motor (microstepping multiplies this)
for (int i = 0; i < 200; i++) {
digitalWrite(PIN_STEP, HIGH);
delayMicroseconds(800); // step high time
digitalWrite(PIN_STEP, LOW);
delayMicroseconds(800); // sets speed
}
delay(500);
digitalWrite(PIN_DIR, !digitalRead(PIN_DIR)); // reverse
delay(500);
}
```
For smooth motion and accel/decels, use AccelStepper library (non-blocking).
**Speed math:**
Steps per rev = motor_steps × microstep (e.g., 200 × 16 = 3200).
Pulse frequency (Hz) = target_RPM × steps_per_rev / 60.
**B) Bipolar stepper + TMC2208/2209 (quiet, smart drivers)**
* Wiring is similar to A4988 (STEP/DIR).
* They’re quieter (stealthChop), support UART config (2208/2209), and stallGuard (2209).
* Start in STEP/DIR mode first; add UART later for current/microstep tuning in code.
Quick wiring:
* VMOT + GND (motor PSU), 100 µF cap
* A1/A2, B1/B2 to coils
* VIO → 5V (or 3.3V on some boards)
* STEP/DIR/EN → Arduino pins
* (Optional) UART pin to an [Arduino](https://www.ampheoelec.de/c/development-board-arduino) pin via a resistor for configuration
**C) 28BYJ-48 (5-wire unipolar) + ULN2003 driver board (super cheap kit)**
**1) Wiring**
* ULN2003 IN1..IN4 → Arduino D8..D11 (for example)
* ULN2003 board +5V → external 5V (can be USB 5V if current allows)
* ULN2003 GND → Arduino GND
* 28BYJ-48 5-pin JST → ULN2003 OUT header (just plug it)
**2) Code (Arduino Stepper library)**
```
#include <Stepper.h>
const int STEPS_PER_REV = 2048; // approx for 28BYJ-48
Stepper motor(STEPS_PER_REV, 8, 10, 9, 11); // IN1, IN3, IN2, IN4
void setup() { motor.setSpeed(10); } // RPM
void loop() {
motor.step(STEPS_PER_REV); // one rev forward
delay(500);
motor.step(-STEPS_PER_REV); // one rev back
delay(500);
}
```
ULN2003 has built-in flyback diodes—no extra diodes needed.
**Power & protection checklist**
* Size the power supply for phase current × number of energized phases + margin.
* Heatsink the driver if you run close to rated current.
* Keep motor wires short/twisted; add bulk electrolytic + small ceramic caps near VMOT.
* Use limit switches (NC preferred) and home your axis at startup.
* If you miss steps at speed, add acceleration, increase voltage (within driver spec), and tune current/microstepping.
**Quick “what should I buy?” picks**
* General purpose NEMA-17: A4988 or DRV8825 + 12 V PSU, 100 µF cap.
* Quiet 3D-printer-style motion: TMC2209 + 24 V PSU for headroom.
* Tiny & cheap learning project: 28BYJ-48 + ULN2003 @ 5 V.