Source: https://mokxi.com/learn/stepper-motor-wiring

Learn

# Stepper motor wiring: find the coils, then wire 4, 5 or 6 wires

Written by the Mokxi team

Start building free

Or see every lesson.

- 455 parts on the bench
- 43 boards running now
- 1.00x real time, on every board

Click to open it in the editor

Black to green reads the coil, 1.50 ohms. Red to green reads OL, because they are on different coils.

Every stepper is coils, and wiring one comes down to two questions: which wires belong to the same coil, and what kind of driver those coils want. A meter answers the first, and the number of wires answers the second.

The circuit above is a NEMA 17 with two multimeters set to ohms. The one across black and green reads 1.50 ohms: that is a coil. The one across red and green reads OL, open: those two wires are on different coils, with no path between them. Press Run to read them.

Below are the three kinds of motor you will meet, with a circuit that runs for each kind Mokxi has: the five-wire 28BYJ-48 on its ULN2003 board and the four-wire NEMA 17 on an A4988.

## Find the coil pairs with a meter

Set the meter to its lowest ohms range and try the wires two at a time. Two wires of one coil read a few ohms on a NEMA 17 (1.50 on Mokxi’s) and tens of ohms on a small motor. Two wires from different coils read open. Four wires make six pairs to try, and exactly two of them read a coil: those are the pairs. In Mokxi, black to green and red to blue each read 1.50 ohms, and the other four pairs read OL.

Which end of a coil goes where does not matter for getting it to turn: swapping a coil’s two wires only reverses the direction. With no meter, there is an old bench trick: twist two wires together and turn the shaft by hand. If it suddenly turns stiffly, those two are a coil, because the shorted coil acts as a brake.

## Four wires: a bipolar motor such as the NEMA 17

Four wires are two coils with no common. Current has to flow through each coil both ways, so the motor needs two H bridges: an A4988, a DRV8825 or an L298N. A ULN2003 cannot run it, because each of its channels can only pull a wire to ground.

The pairing is what matters: black and green on one output pair, red and blue on the other, as in the table. In Mokxi, with one wire of each coil on each output pair, 50 steps left the shaft where it powered up; with black and green swapped on their two pins, the motor turned 90 degrees the other way, which is harmless.

A NEMA 17 with black and green on coil A, as Mokxi’s is, on either driver
Motor wire | Coil | A4988 pin | DRV8825 pin

Black (A1) | A | 2B | B2

Green (A2) | A | 2A | B1

Red (B1) | B | 1A | A1

Blue (B2) | B | 1B | A2

## Five wires: the 28BYJ-48, unipolar

Five wires are four coil ends and a common. On the 28BYJ-48 the red wire is the common and goes to +5 V, and each of the other four is the far end of one coil. A ULN2003 channel pulls one end to ground, current flows through that coil, and it becomes a magnet; switching them in order walks the rotor around. Each coil is 50 ohms ±7 percent on Kiatronics’ 5 V datasheet, and Mokxi’s model uses 50, so red to any other wire reads one coil and two colored wires read two coils in series, about twice as much.

The plug is keyed and fits the board one way, so the motor end needs no thought. Wire the board’s IN1 to IN4 to four Arduino pins, + to 5 V and − to GND, and name the pins IN1, IN3, IN2, IN4 in the Stepper and AccelStepper libraries. Mokxi models the motor and its board as one part, so its coils are not on pins a meter can reach; the stepper dial runs one on pins 8 to 11.

## Six wires: two coils with center taps

A six-wire motor has two coils with a wire from the middle of each, a center tap. A meter finds the groups: three wires connect to each other and to none of the other three. Inside a group, the two ends read twice what either end reads to the middle, so the middle wire is the one that reads the smaller value to both of the others.

Wired as unipolar, the two taps go to the supply and the four ends to a ULN2003 style driver, which is the 28BYJ-48’s arrangement with its two taps joined inside. Wired as bipolar, leave the taps unconnected and put each coil’s two ends on one output pair of an A4988 or a DRV8825. Mokxi has no six-wire motor, so this section comes from the bench rather than the engine. Eight-wire motors are four half coils, joined in series or in parallel for a bipolar driver; follow the maker’s diagram.

## Color codes vary: trust the meter

There is no standard. StepperOnline’s 17HS19-2004S1 datasheet gives black A+, green A−, red B+ and blue B−, the same pairs Mokxi’s NEMA 17 has, and other makers use other colors and other pairs. Fulling’s 28BYJ-48 sheet energizes the four coil leads in the order orange, yellow, pink and blue for one direction. Use a color code to label the wires once a meter has confirmed it, not instead of one.

## Questions

How do I tell which stepper wires are a pair?

Measure ohms between two wires at a time. The two wires of one coil read a few ohms on a NEMA 17; wires from different coils read open. A four-wire motor has exactly two pairs.

What is the difference between a 4-wire and a 6-wire stepper?

A 4-wire motor is two coils, bipolar, for an A4988 or DRV8825. A 6-wire motor is two coils each with a center tap: run it unipolar with the taps on the supply, or bipolar with the taps left unconnected.

What do the 28BYJ-48 wire colors mean?

Red is the common, on +5 V. Orange, yellow, pink and blue are the far ends of the four coils, which the ULN2003 board pulls to ground in turn.

Does it matter which end of a coil goes to which driver pin?

Only for the direction. Swapping one coil’s two wires makes the motor turn the other way; putting wires of different coils on one output pair stops it turning at all.

Related

## Keep going

Stepper Motor Vibrating but Not Turning: Fixes Arduino Stepper Motor: 28BYJ-48 and ULN2003 Arduino A4988 and NEMA 17 Stepper: Wiring and Code A4988 Pinout: Pins, Microstep Table and Vref Arduino DRV8825: Wiring, Code and Microstepping AccelStepper Arduino Library: Examples and Homing Arduino L298N Motor Driver: Wiring, Jumpers and Code The 28BYJ-48, pin by pin The NEMA 17 stepper motor The multimeter

Sources

## Where the facts on this page come from

- StepperOnline 17HS19-2004S1 datasheet: black A+, green A−, red B+, blue B−
- Fulling 28BYJ-48 datasheet: the coil leads and their switching sequence
- Kiatronics 28BYJ-48 5 V datasheet: 50 ohms per coil

## Build this for real

Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.

Start building free Open the editor
