Spin a Stepper Motor (28BYJ-48 + Arduino)
Turn a 28BYJ-48 stepper one revolution each way through its ULN2003 driver. Learn the Stepper library.
Beginner20 min
What you need
- · External 5V supply (recommended)
- · Breadboard
- · jumper wires
Wiring
Hover a pin or a wire to trace the connection.
Code
stepper.ino
// Rotate a 28BYJ-48 one revolution each direction.
#include <Stepper.h>
const int stepsPerRev = 2048; // 28BYJ-48 (geared)
// ULN2003 coil order for the Stepper library: IN1, IN3, IN2, IN4
Stepper motor(stepsPerRev, 8, 10, 9, 11);
void setup() {
motor.setSpeed(10); // RPM
}
void loop() {
motor.step(stepsPerRev); // one turn clockwise
delay(1000);
motor.step(-stepsPerRev); // one turn back
delay(1000);
}
Steps
- Wire IN1–IN4 to D8–D11; power the driver board from 5V (external supply preferred).
- Note the library pin order is IN1, IN3, IN2, IN4 — that's why the code reads 8, 10, 9, 11.
- Upload — the shaft turns one revolution each way.
- If it just buzzes, check the coil order and use a separate 5V supply.