Hamza khan
Published

ESP32 with Stepper Motor 28BYJ-48 and ULN2003 Motor Driver

The article explores the integration of the ESP32 microcontroller with the Stepper Motor 28BYJ-48 and the ULN2003 Motor Driver.

IntermediateFull instructions provided5,412
ESP32 with Stepper Motor 28BYJ-48 and ULN2003 Motor Driver

Things used in this project

Hardware components

ESP32
Espressif ESP32
×1
LED (generic)
LED (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
28BYJ-48
×1

Story

Read more

Schematics

esp32_stepper_motor_28byj-48_circuit_C8wZVXYqOQ.png

Code

Untitled file

Arduino
#include <Stepper.h>

const int stepsPerRevolution = 2048;  // change this to fit the number of steps per revolution

// ULN2003 Motor Driver Pins
#define IN1 19
#define IN2 18
#define IN3 5
#define IN4 17

// initialize the stepper library
Stepper myStepper(stepsPerRevolution, IN1, IN3, IN2, IN4);

void setup() {
  // set the speed at 5 rpm
  myStepper.setSpeed(5);
  // initialize the serial port
  Serial.begin(115200);
}

void loop() {
  // step one revolution in one direction:
  Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  delay(1000);

  // step one revolution in the other direction:
  Serial.println("counterclockwise");
  myStepper.step(-stepsPerRevolution);
  delay(1000);
}

Credits

Hamza khan

Hamza khan

13 projects • 1 follower

Comments