Arduino Stepper Library 28BYJ-48: Wiring, Code and Simulator
To build this Arduino Stepper Library 28BYJ-48 project you need an Arduino Uno and a stepper 28BYJ-48 + ULN2003. Arduino's Stepper library turns a 28BYJ-48 a quarter turn through its ULN2003 board. Make the 6 connections in the wiring table, upload the Arduino C++ code, and step -512 to come back, or raise setSpeed().
Open this circuit in the free Arduino Uno simulator
Parts list
| Qty | Part | What it does |
|---|---|---|
| 1 | Arduino Uno | the microcontroller board |
| 1 | Stepper 28BYJ-48 + ULN2003 | The kit stepper with its driver board: IN1–IN4 to four pins, + to 5 V, − to GND. 2048 full steps per turn; with Stepper use pin order IN1, IN3, IN2, IN4. |
Wiring
| # | From | To |
|---|---|---|
| 1 | Arduino Uno pin 8 | Stepper 28BYJ-48 + ULN2003 IN1 |
| 2 | Arduino Uno pin 9 | Stepper 28BYJ-48 + ULN2003 IN2 |
| 3 | Arduino Uno pin 10 | Stepper 28BYJ-48 + ULN2003 IN3 |
| 4 | Arduino Uno pin 11 | Stepper 28BYJ-48 + ULN2003 IN4 |
| 5 | Arduino Uno 5V | Stepper 28BYJ-48 + ULN2003 + |
| 6 | Arduino Uno GND | Stepper 28BYJ-48 + ULN2003 - |
Step by step
- Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Arduino Uno. No install or account is needed.
- Add the parts. Add a stepper 28BYJ-48 + ULN2003 from the parts palette.
- Wire 1. Connect Arduino Uno pin 8 to Stepper 28BYJ-48 + ULN2003 IN1.
- Wire 2. Connect Arduino Uno pin 9 to Stepper 28BYJ-48 + ULN2003 IN2.
- Wire 3. Connect Arduino Uno pin 10 to Stepper 28BYJ-48 + ULN2003 IN3.
- Wire 4. Connect Arduino Uno pin 11 to Stepper 28BYJ-48 + ULN2003 IN4.
- Wire 5. Connect Arduino Uno 5V to Stepper 28BYJ-48 + ULN2003 +.
- Wire 6. Connect Arduino Uno GND to Stepper 28BYJ-48 + ULN2003 -.
- Paste the Arduino C++ code. Paste the Arduino C++ code below into the code editor.
- Run it. Press Run. Step -512 to come back, or raise setSpeed().
Arduino C++ code
// Stepper (Arduino): a 28BYJ-48 through a ULN2003 board on pins 8-11.
#include <Stepper.h>
const int stepsPerRev = 2048;
Stepper motor(stepsPerRev, 8, 10, 9, 11);
void setup() {
Serial.begin(9600);
motor.setSpeed(10);
motor.step(512);
Serial.println("Quarter turn done.");
}
void loop() {}
What to try
Step -512 to come back, or raise setSpeed().
Frequently asked questions
How do I wire the Stepper Library 28BYJ-48 project on an Arduino Uno?
Make 6 connections: Arduino Uno pin 8 to Stepper 28BYJ-48 + ULN2003 IN1; Arduino Uno pin 9 to Stepper 28BYJ-48 + ULN2003 IN2; Arduino Uno pin 10 to Stepper 28BYJ-48 + ULN2003 IN3; Arduino Uno pin 11 to Stepper 28BYJ-48 + ULN2003 IN4; Arduino Uno 5V to Stepper 28BYJ-48 + ULN2003 +; Arduino Uno GND to Stepper 28BYJ-48 + ULN2003 -.
What parts do I need for this Arduino project?
An Arduino Uno and a stepper 28BYJ-48 + ULN2003.
Can I simulate this Arduino project online for free?
Yes. The BitForBytes Embedded Lab runs this exact circuit and Arduino C++ code in your browser for free, with no install and no hardware. The sketch is compiled with the real Arduino toolchain and runs on an emulated ATmega328P.
What does the code do?
Arduino's Stepper library turns a 28BYJ-48 a quarter turn through its ULN2003 board.
More Arduino Uno projects
- Arduino LED Blink: Wiring, Code and Simulator
- Arduino LDR Light Sensor: Wiring, Code and Simulator
- Arduino NTC Thermistor Thermometer: Wiring, Code and Simulator
- Arduino PWM to Analog RC Filter: Wiring, Code and Simulator
- Arduino Capacitance Meter: Wiring, Code and Simulator
- Arduino DC Motor PWM Speed Control with MOSFET: Wiring, Code and Simulator