ESP32 C3 Super Mini - 28BYJ-48 Stepper Motor ULN2003 Driver

Learn how to control the 28BYJ-48 stepper motor using the ESP32 C3 Super Mini and ULN2003 driver module for precise position control in your Arduino projects. This tutorial shows you how to wire, program, and control one or multiple stepper motors with simple code examples.

In this ESP32 C3 Super Mini stepper motor tutorial, you'll learn:

ESP32 C3 Super Mini ULN2003 28BYJ-48 stepper motor

Why use stepper motors with ESP32 C3 Super Mini:

Hardware Preparation

1×ESP32 C3 Super Mini
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×28BYJ-48 stepper motor + ULN2003 Driver Module
1×5V Power Adapter
1×DC Power Jack
1×Jumper Wires

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Overview of 28BYJ-48 Stepper Motor

The 28BYJ-48 is a small unipolar stepper motor that provides precise position control through stepped rotation.

Key specifications of the 28BYJ-48 stepper motor:

  • Step angle: 11.25 degrees in full-step mode (32 steps per revolution)
  • Gear ratio: 1/64 reduction gear set included
  • Total steps: 2048 steps per full revolution (32 × 64)
  • Step precision: Approximately 0.1758 degrees per step (360°/2048)
  • Operating voltage: 5V DC
  • Interface: 5-pin connector that plugs directly into ULN2003 driver
  • Torque: Low to medium torque suitable for light applications
  • Cost: Very affordable for beginners learning stepper motor control

Important: When using the 28BYJ-48 stepper motor in full-step mode, it requires 2048 steps to complete one full revolution.

28BYJ-48 Stepper Motor Pinout

The 28BYJ-48 stepper motor has 5 pins on its connector.

  • Pin 1-5: Internal motor coil connections
  • Connector: Male 5-pin connector that plugs into ULN2003 driver

Note: You don't need to worry about individual pin connections - simply plug the motor's connector directly into the ULN2003 driver module's socket.

28BYJ-48 stepper motor

Overview of ULN2003 Stepper Motor Driver Module

The ULN2003 is a popular and easy-to-use driver module specifically designed for controlling stepper motors with Arduino and ESP32 boards.

Key features of the ULN2003 driver module:

  • 4 control inputs: IN1, IN2, IN3, IN4 for motor control signals
  • LED indicators: Four onboard LEDs show real-time stepping activity
  • Power control: ON/OFF jumper for easy motor power management
  • Power supply: Separate power input (5V-12V) for the stepper motor
  • Easy wiring: Direct plug-in connector for 28BYJ-48 motor
  • Protection: Built-in protection for your microcontroller
  • Beginner-friendly: Simple to wire and program

ULN2003 Driver Pinout

The ULN2003 module has 6 pins and one female connector for easy stepper motor control.

ULN2003 Stepper Motor Driver Pinout
  • IN1: Control input pin 1 - connects to ESP32 C3 Super Mini digital pin
  • IN2: Control input pin 2 - connects to ESP32 C3 Super Mini digital pin
  • IN3: Control input pin 3 - connects to ESP32 C3 Super Mini digital pin
  • IN4: Control input pin 4 - connects to ESP32 C3 Super Mini digital pin
  • GND: Ground pin - MUST connect to both ESP32 and external power supply ground
  • VDD: Motor power supply input - connects to external 5V power source
  • Motor Connector: Female socket where the 28BYJ-48 motor plugs in

※ NOTE THAT:

Important power supply notes for stepper motor operation:

  • Always match the external power supply voltage to your motor's specifications
  • The 28BYJ-48 stepper motor requires 5V DC external power supply
  • Never connect the VDD pin to the ESP32 C3 Super Mini's 5V pin
  • Stepper motors draw high current that can damage your ESP32
  • Always use a dedicated external power supply for the motor
  • Connect all grounds together (ESP32 GND, driver GND, power supply GND)

Wiring Diagram

This diagram shows how to connect the 28BYJ-48 stepper motor to the ESP32 C3 Super Mini using the ULN2003 driver module.

The wiring diagram between ESP32 C3 Super Mini stepper motor ULN2003 driver

This image is created using Fritzing. Click to enlarge image

Wiring connections for ESP32 C3 Super Mini and ULN2003 driver:

ULN2003 Pin ESP32 C3 Super Mini Pin
IN1 GPIO8
IN2 GPIO9
IN3 GPIO10
IN4 GPIO20
GND GND
VDD 5V External Power Supply
Motor Connector 28BYJ-48 Motor Connector
Power Supply GND GND (shared with ESP32 and ULN2003)

Note: The wire colors on the 28BYJ-48 stepper motor don't matter - simply plug the male connector into the female connector on the ULN2003 driver module.

How To Program to Control a Stepper Motor

Understanding stepper motor control methods helps you choose the right approach for your ESP32 C3 Super Mini project.

Three main stepper motor control methods:

  • Full-Step: Basic method, provides full torque, suitable for most beginner projects
  • Half-Step: Doubles resolution, smoother movement, slightly reduced torque
  • Micro-Step: Highest resolution, smoothest operation, requires specialized drivers

Why we recommend the AccelStepper library:

  • Non-blocking operation: ESP32 C3 Super Mini can perform other tasks while controlling the motor
  • Smooth acceleration: Gradual speed changes prevent motor stalling
  • Multiple motor support: Control several stepper motors independently and simultaneously
  • Flexible control: Supports both full-step and half-step driving modes
  • Easy to use: Simple functions for beginners

Why avoid the built-in Arduino Stepper library:

  • Blocking: Freezes ESP32 during motor operation
  • Limited features: Lacks acceleration and advanced control
  • Poor multi-motor support: Cannot control multiple motors efficiently

Note: The AccelStepper library does not support micro-step driving, but this is rarely needed for beginner projects.

ESP32 C3 Super Mini Code - Single Stepper Motor

This code demonstrates how to control one 28BYJ-48 stepper motor using the ESP32 C3 Super Mini and AccelStepper library.

What this stepper motor code does:

  • Initializes the stepper motor with proper settings for 28BYJ-48
  • Rotates one full revolution clockwise
  • Rotates two full revolutions counter-clockwise
  • Rotates two full revolutions clockwise
  • Repeats this pattern continuously
  • Uses acceleration for smooth motor movement
/* * This ESP32 C3 Super Mini code was developed by newbiely.com * * This ESP32 C3 Super Mini code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-c3/esp32-c3-super-mini-28byj-48-stepper-motor-uln2003-driver */ // Include the AccelStepper Library #include <AccelStepper.h> #define STEP_PER_REVOLUTION 2048 // this value is from datasheet #define PIN_IN1 8 // The ESP32 C3 SuperMini pin GPIO8 connected to the IN1 pin of ULN2003 driver #define PIN_IN2 9 // The ESP32 C3 SuperMini pin GPIO9 connected to the IN2 pin of ULN2003 driver #define PIN_IN3 10 // The ESP32 C3 SuperMini pin GPIO10 connected to the IN3 pin of ULN2003 driver #define PIN_IN4 20 // The ESP32 C3 SuperMini pin GPIO20 connected to the IN4 pin of ULN2003 driver // The pins are entered in sequence IN1-IN3-IN2-IN4 for proper step sequence AccelStepper stepper(AccelStepper::FULL4WIRE, PIN_IN1, PIN_IN3, PIN_IN2, PIN_IN4); int stage = 0; // which move of the pattern is running long lastPrinted = 0; // the last position shown on Serial Monitor void startMove(long steps, const char* message) { Serial.println(message); stepper.move(steps); } void setup() { Serial.begin(115200); Serial.println("Stepper motor test starting..."); stepper.setMaxSpeed(1000.0); // set the maximum speed stepper.setAcceleration(50.0); // set acceleration stepper.setCurrentPosition(0); // set position startMove(STEP_PER_REVOLUTION, "Moving clockwise 1 revolution (2048 steps)"); } void loop() { stepper.run(); // MUST be called in loop() function // show the position every 500 steps long position = stepper.currentPosition(); if (position % 500 == 0 && position != lastPrinted) { Serial.print("Position: "); Serial.println(position); lastPrinted = position; } // start the next move once the motor reaches the target position if (stepper.distanceToGo() == 0) { Serial.print("Position: "); Serial.println(position); lastPrinted = position; stage++; if (stage == 1) { startMove(-2 * STEP_PER_REVOLUTION, "Moving counter-clockwise 2 revolutions (-4096 steps)"); } else if (stage == 2) { startMove(2 * STEP_PER_REVOLUTION, "Moving clockwise 2 revolutions (4096 steps)"); } else { Serial.println("Cycle complete!"); stage = 0; stepper.setCurrentPosition(0); lastPrinted = 0; startMove(STEP_PER_REVOLUTION, "Moving clockwise 1 revolution (2048 steps)"); } } }

Detailed Instructions

  • New to ESP32 C3 Mini? Complete our Getting Started with ESP32 C3 Mini tutorial first to set up your development environment.
  • Install AccelStepper library: Open Library Manager in Arduino IDE, search "AccelStepper", and install the library by Mike McCauley
  • Search for AccelStepper created by Mike McCauley and click the Install button.
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32C3 Dev Module
Library Manager
Type:
All
Topic:
All
AccelStepper by Mike McCauley
Provides an object-oriented interface for 2, 3 or 4 pin stepper motors and motor drivers. More info
1.64
INSTALL
Newbiely.ino
···
1 void setup() {
Output
Serial Monitor
Ln 1, Col 1
ESP32C3 Dev Module on COM15
1
  • Set up environment: If new to ESP32 C3 Super Mini, follow the setup tutorial first
  • Wire components: Connect the stepper motor and ULN2003 driver according to the wiring diagram above
  • Connect ESP32: Plug your ESP32 C3 Super Mini into your computer with a USB Type-C cable
  • Select board: Choose "ESP32 C3 Super Mini" and the correct COM port in Arduino IDE
  • Upload code: Copy the code, paste it into Arduino IDE, and click Upload
  • Observe motor: Watch the stepper motor rotate in the programmed pattern (1 rev CW, 2 rev CCW, 2 rev CW, repeat)
  • Open Serial Monitor: View status messages at 115200 baud rate
  • Pro Tip: Adjust the setMaxSpeed() and setAcceleration() values to change motor speed and smoothness - lower values make slower, smoother movements.

Serial Monitor Output

∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32C3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32C3 Dev Module' on 'COM15')
New Line
9600 baud
Stepper motor test starting... Moving clockwise 1 revolution (2048 steps) Position: 500 Position: 1000 Position: 1500 Position: 2048 Moving counter-clockwise 2 revolutions (-4096 steps) Position: 1500 Position: 1000 Position: 500 Position: 0 Position: -500 Position: -1000 Position: -1500 Position: -2000 Position: -2500 Position: -3000 Position: -3500 Position: -4096 Moving clockwise 2 revolutions (4096 steps) Position: -3500 Position: -3000 Position: -2500 Position: -2000 Position: -1500 Position: -1000 Position: -500 Position: 0 Cycle complete!
Ln 11, Col 1
ESP32C3 Dev Module on COM15
2

How to Control Multiple 28BYJ-48 Stepper Motors

Learn how to control two or more stepper motors independently at the same time using the ESP32 C3 Super Mini.

Benefits of controlling multiple stepper motors:

  • Each motor moves independently with different speeds and directions
  • Perfect for robotics projects requiring coordinated movement
  • ESP32 has enough pins to control 2-3 stepper motors easily
  • AccelStepper library handles simultaneous control smoothly

Wiring Diagram for Two 28BYJ-48 Stepper Motors

This diagram shows how to connect two stepper motors to the ESP32 C3 Super Mini using two ULN2003 driver modules.

The wiring diagram between ESP32 C3 Super Mini two stepper motor ULN2003 driver

This image is created using Fritzing. Click to enlarge image

Wiring connections for two stepper motors:

Component ESP32 C3 Super Mini Pin
ULN2003 #1 - IN1 GPIO8
ULN2003 #1 - IN2 GPIO9
ULN2003 #1 - IN3 GPIO10
ULN2003 #1 - IN4 GPIO20
ULN2003 #2 - IN1 GPIO2
ULN2003 #2 - IN2 GPIO3
ULN2003 #2 - IN3 GPIO4
ULN2003 #2 - IN4 GPIO5
Both ULN2003 GND GND
Both ULN2003 VDD 5V External Power Supply
Power Supply GND GND (shared with ESP32 and both drivers)

Note: Both ULN2003 modules share the same external 5V power supply and common ground with the ESP32 C3 Super Mini.

ESP32 C3 Super Mini Code for Two 28BYJ-48 Stepper Motors

This code demonstrates simultaneous control of two stepper motors with independent movement patterns.

What this multi-stepper code does:

  • Controls two stepper motors completely independently
  • Each motor rotates at different speeds
  • Motors move in opposite directions
  • Demonstrates non-blocking operation
  • Shows how to coordinate multiple motors in one program
/* * This ESP32 C3 Super Mini code was developed by newbiely.com * * This ESP32 C3 Super Mini code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-c3/esp32-c3-super-mini-28byj-48-stepper-motor-uln2003-driver */ // Include the AccelStepper Library #include <AccelStepper.h> // define step constant #define FULLSTEP 4 #define STEP_PER_REVOLUTION 2048 // this value is from datasheet // The ESP32 C3 SuperMini pins connected to the IN1, IN2, IN3, IN4 pins of the first ULN2003 driver #define PIN_1_IN1 8 #define PIN_1_IN2 9 #define PIN_1_IN3 10 #define PIN_1_IN4 20 // The ESP32 C3 SuperMini pins connected to the IN1, IN2, IN3, IN4 pins of the second ULN2003 driver #define PIN_2_IN1 2 #define PIN_2_IN2 3 #define PIN_2_IN3 4 #define PIN_2_IN4 5 // The pins are entered in sequence IN1-IN3-IN2-IN4 for proper step sequence AccelStepper stepper_1(FULLSTEP, PIN_1_IN1, PIN_1_IN3, PIN_1_IN2, PIN_1_IN4); AccelStepper stepper_2(FULLSTEP, PIN_2_IN1, PIN_2_IN3, PIN_2_IN2, PIN_2_IN4); unsigned long lastPrintTime = 0; void setup() { Serial.begin(115200); stepper_1.setMaxSpeed(500.0); // the first motor is the faster one stepper_1.setAcceleration(50.0); // set acceleration stepper_1.setCurrentPosition(0); // set position stepper_1.moveTo(STEP_PER_REVOLUTION); // set target position: one revolution stepper_2.setMaxSpeed(300.0); // the second motor is the slower one stepper_2.setAcceleration(50.0); // set acceleration stepper_2.setCurrentPosition(0); // set position stepper_2.moveTo(-STEP_PER_REVOLUTION); // set target position: one revolution, in the opposite direction } void loop() { // change direction once the motor reaches target position if (stepper_1.distanceToGo() == 0) stepper_1.moveTo(-stepper_1.currentPosition()); if (stepper_2.distanceToGo() == 0) stepper_2.moveTo(-stepper_2.currentPosition()); stepper_1.run(); // MUST be called in loop() function stepper_2.run(); // MUST be called in loop() function // show the positions once a second: printing on every loop would slow the motors down if (millis() - lastPrintTime >= 1000) { lastPrintTime = millis(); Serial.print(F("stepper_1# current position: ")); Serial.println(stepper_1.currentPosition()); Serial.print(F("stepper_2# current position: ")); Serial.println(stepper_2.currentPosition()); } }

Applications and Project Ideas

Use the ESP32 C3 Super Mini with 28BYJ-48 stepper motors in these exciting projects:

  • Camera slider: Build an automated camera dolly for smooth time-lapse videos
  • XY plotter: Create a drawing robot that plots designs on paper
  • Automatic blinds: Control window blinds with scheduled or remote operation
  • Pan-tilt mechanism: Make a camera mount that rotates horizontally and vertically
  • Analog clock: Design a large wall clock with precise stepper motor hands
  • Conveyor belt: Build a small sorting or transport system for objects
  • Solar tracker: Create a panel that follows the sun throughout the day
  • Robotic arm: Construct a simple 2-3 axis arm for pick-and-place tasks

Video Tutorial

Watch the video below for a visual walkthrough of this project.

...VIDEO https://www.youtube.com/watch?v=EXAMPLE_VIDEO_ID_HERE

...VIDEO

Challenge Yourself

Test your ESP32 C3 Super Mini stepper motor skills with these progressively challenging exercises:

  • Easy: Modify the code to make the motor rotate 5 full revolutions clockwise, then stop
  • Easy: Change the motor speed by adjusting setMaxSpeed() to make it rotate twice as fast
  • Medium: Create a pattern where the motor rotates 45 degrees, pauses 1 second, then repeats
  • Medium: Add a push button that reverses the motor direction when pressed
  • Advanced: Build a simple clock with two stepper motors for hour and minute hands
  • Advanced: Create a program that accepts Serial Monitor commands to control motor position (e.g., "MOVE 1000" or "HOME")

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!