Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Controlled 28BYJ-48 Stepper Motor with ULN2003 Driver

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled 28BYJ-48 Stepper Motor with ULN2003 Driver

Circuit Documentation

Summary

This circuit controls a 28BYJ-48 stepper motor using an Arduino UNO and a ULN2003 driver. The Arduino UNO provides the control signals to the ULN2003 driver, which in turn drives the stepper motor. The motor will rotate in one direction for a specified number of steps, then reverse direction for the same number of steps.

Component List

  1. Arduino UNO

    • Description: A microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. 28BYJ-48 Stepper Motor

    • Description: A small, inexpensive stepper motor commonly used in hobby projects.
    • Pins: BLUE, PINK, YELLOW, ORANGE, RED
  3. ULN2003

    • Description: A Darlington transistor array used to drive the stepper motor.
    • Pins: IN1, IN2, IN3, IN4, IN5, IN6, IN7, GND, +, COIL1, COIL2, COIL3, COIL4, COIL5

Wiring Details

Arduino UNO

28BYJ-48 Stepper Motor

ULN2003

Code Documentation

/*
 * Przykładowy program demonstujący działanie silnika krokowego.
 * This code controls a 28BYJ-48 stepper motor using an Arduino UNO and a
 * ULN2003 driver. The motor will rotate in one direction for a few steps,
 * then reverse direction for the same number of steps.
 */

// Define the pins connected to the ULN2003 driver
#define IN1 7
#define IN2 6
#define IN3 5
#define IN4 4

// Number of steps per revolution for 28BYJ-48
const int stepsPerRevolution = 2048;

void setup() {
  // Set the pins as outputs
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
}

void loop() {
  // Rotate the motor in one direction
  for (int i = 0; i < stepsPerRevolution; i++) {
    stepMotor(i % 4);
    delay(2);
  }
  delay(1000);
  // Rotate the motor in the opposite direction
  for (int i = stepsPerRevolution; i > 0; i--) {
    stepMotor(i % 4);
    delay(2);
  }
  delay(1000);
}

void stepMotor(int step) {
  switch (step) {
    case 0:
      digitalWrite(IN1, HIGH);
      digitalWrite(IN2, LOW);
      digitalWrite(IN3, LOW);
      digitalWrite(IN4, LOW);
      break;
    case 1:
      digitalWrite(IN1, LOW);
      digitalWrite(IN2, HIGH);
      digitalWrite(IN3, LOW);
      digitalWrite(IN4, LOW);
      break;
    case 2:
      digitalWrite(IN1, LOW);
      digitalWrite(IN2, LOW);
      digitalWrite(IN3, HIGH);
      digitalWrite(IN4, LOW);
      break;
    case 3:
      digitalWrite(IN1, LOW);
      digitalWrite(IN2, LOW);
      digitalWrite(IN3, LOW);
      digitalWrite(IN4, HIGH);
      break;
  }
}

This code sets up the Arduino UNO to control the ULN2003 driver, which in turn drives the 28BYJ-48 stepper motor. The motor will rotate in one direction for a specified number of steps, then reverse direction for the same number of steps.