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

QtyPartWhat it does
1Arduino Unothe microcontroller board
1Stepper 28BYJ-48 + ULN2003The 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

#FromTo
1Arduino Uno pin 8Stepper 28BYJ-48 + ULN2003 IN1
2Arduino Uno pin 9Stepper 28BYJ-48 + ULN2003 IN2
3Arduino Uno pin 10Stepper 28BYJ-48 + ULN2003 IN3
4Arduino Uno pin 11Stepper 28BYJ-48 + ULN2003 IN4
5Arduino Uno 5VStepper 28BYJ-48 + ULN2003 +
6Arduino Uno GNDStepper 28BYJ-48 + ULN2003 -

Step by step

  1. Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Arduino Uno. No install or account is needed.
  2. Add the parts. Add a stepper 28BYJ-48 + ULN2003 from the parts palette.
  3. Wire 1. Connect Arduino Uno pin 8 to Stepper 28BYJ-48 + ULN2003 IN1.
  4. Wire 2. Connect Arduino Uno pin 9 to Stepper 28BYJ-48 + ULN2003 IN2.
  5. Wire 3. Connect Arduino Uno pin 10 to Stepper 28BYJ-48 + ULN2003 IN3.
  6. Wire 4. Connect Arduino Uno pin 11 to Stepper 28BYJ-48 + ULN2003 IN4.
  7. Wire 5. Connect Arduino Uno 5V to Stepper 28BYJ-48 + ULN2003 +.
  8. Wire 6. Connect Arduino Uno GND to Stepper 28BYJ-48 + ULN2003 -.
  9. Paste the Arduino C++ code. Paste the Arduino C++ code below into the code editor.
  10. 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