Motor
Controlling Stepper 28BYJ48 Motor with ESP32
What is the Stepper 28BYJ48?
A cheap 5V geared stepper motor bundled with the ULN2003 driver board, common in camera sliders and small CNC-style projects.
Specifications
| Motor type | 5-wire unipolar stepper with internal ~1:64 gear reduction |
| Step angle | 5.625°/64 per internal step — roughly 4096 half-steps per output-shaft revolution through the gearbox |
| Operating voltage | 5 V DC (matches the bundled ULN2003 driver board; a 12V-coil variant also exists) |
| Driver IC | ULN2003 Darlington transistor array, 4 inputs (IN1-IN4) |
| Current draw | ~240 mA per phase — low torque, not suited to driving loads heavier than light gears or small pointers |
Stepper 28BYJ48 Pinout
| Pin | Name | Description |
|---|---|---|
| 1 | IN1 | Coil control input 1 — connect to a digital output pin |
| 2 | IN2 | Coil control input 2 — connect to a digital output pin |
| 3 | IN3 | Coil control input 3 — connect to a digital output pin |
| 4 | IN4 | Coil control input 4 — connect to a digital output pin |
| 5 | - | Ground, on the driver board's power terminal |
| 6 | + | Power, 5V DC, on the driver board's power terminal — the motor's 5-pin JST plugs directly into the driver, no separate motor wiring needed |
The motor connects to the driver board via its own keyed JST connector, not loose wires — only IN1-IN4 and the power terminal go to your microcontroller and supply.
Setting Up Stepper 28BYJ48 with ESP32
Library
AccelStepper by Mike McCauley
Arduino IDE → Tools → Manage Libraries → search "AccelStepper"
Wiring
| Component pin | ESP32 pin | Note |
|---|---|---|
| IN1 | GPIO14 | — |
| IN2 | GPIO27 | — |
| IN3 | GPIO26 | — |
| IN4 | GPIO25 | — |
| + | 5V (external supply recommended) | The ULN2003 board's onboard regulation is minimal -- an external 5V supply avoids brownouts on the ESP32 when the motor is under load |
| - | GND | Common ground with the ESP32 is required even with an external supply |
Example code
AccelStepper's HALF4WIRE mode expects pins in IN1-IN3-IN2-IN4 order, not IN1-IN2-IN3-IN4 -- get this wrong and the motor buzzes without turning. ~4096 half-steps make one full revolution on the standard 28BYJ-48 gearing.
Related Guides & Projects

ESP32-CAM Web Server: Stream Live Video in 5 Minutes
A complete, no-guesswork walkthrough for flashing an AI-Thinker ESP32-CAM as a live MJPEG video stream -- wiring, Arduino IDE setup, the CameraWebServer sketch, and every failure mode that actually causes problems.

ESP32 MQTT Tutorial: Publish and Subscribe with Arduino IDE
A complete, broker-agnostic ESP32 MQTT tutorial -- topics, QoS, retained messages, Last Will and Testament, TLS security for production, and a working publish/subscribe example with PubSubClient.

Installing ESP8266 in Arduino IDE: NodeMCU (ESP-12E) Complete Setup Guide for Windows
From driver headaches to a blinking LED — the full Windows walkthrough for getting NodeMCU ESP8266 boards running in Arduino IDE, plus notes for Mac and the bare ESP-01 module.

ESP32 Pinout Guide: Every GPIO, ADC, PWM, and Restricted Pin Explained
Complete ESP32 pinout guide covering all GPIOs, input-only pins, strapping pins, flash-reserved pins, dual ADC channels, PWM via LEDC, I2C, SPI, UART, and deep sleep wake pins.