Arduino Uno: 28BYJ-48 stepper motor
28BYJ-48 turns quarter turns.
- Arduino Uno
- 28BYJ-48
Open in the simulatorNo account needed: press Simulate and it runs.
How it works
The 28BYJ-48 geared stepper motor on the ULN2003 driver board (IN1–IN4 on D8–D11) uses the Stepper library to turn a quarter turn forward and back; the shaft rotates in the schematic. With setSpeed above ~15 rpm the motor loses steps (note in the console).
Wiring
Each line is one connection (net) and the pins it joins.
| Net | Pins |
|---|---|
| GND | A1 GNDM1 GNDV1 − |
| 5V | A1 5VM1 5VV1 + |
| IN1 | A1 D8M1 IN1 |
| IN2 | A1 ~D9M1 IN2 |
| IN3 | A1 ~D10/SSM1 IN3 |
| IN4 | A1 ~D11/MOSIM1 IN4 |
Parts
Firmware
sketch.ino · 18 lines
// 28BYJ-48 on ULN2003 (IN1..IN4 = D8..D11): one quarter turn forward and back
#include <Stepper.h>
const int STEPS = 2048; // full steps per turn of the output shaft
Stepper motor(STEPS, 8, 10, 9, 11); // order IN1, IN3, IN2, IN4
void setup() {
Serial.begin(115200);
motor.setSpeed(12); // rpm (above ~15 the motor loses steps)
}
void loop() {
Serial.println(F("90 degrees forward"));
motor.step(STEPS / 4);
delay(500);
Serial.println(F("90 degrees back"));
motor.step(-STEPS / 4);
delay(500);
}Open in the simulator