Stepper Motor(28BYJ-48)
The 28BYJ-48 is a stepper motor that can be used with Arduino and MCU controller boards. This document involves the use of the ULN2003 motor driver.
Specifications
- Operating Voltage: 5V
- Step Angle: 5.625°
- 64-step motor
- Half 4 wire
Example Required Hardware
- Arduino board
- Jumper cables
- Stepper motor (28BYJ-48)
- Stepper motor driver (ULN2003)
Connection
The stepper motor is connected to the motor driver with a connector, which is not detailed here.
Arduino | Stepper Motor Driver |
D12 | IN1 |
D11 | IN2 |
D10 | IN3 |
D9 | IN4 |
VIN | + |
GND | - |
Example Code Overview
The example demonstrates making the stepper motor rotate one full turn clockwise, waiting for 1 second, then one full turn counterclockwise, followed by another 1-second wait, in a repeating loop.
#include <Stepper.h>
#define IN1 12
#define IN2 11
#define IN3 10
#define IN4 9
const int stepsPerRevolution = 2048; // [360/5.625*64/2=2048]
Stepper step1(stepsPerRevolution, IN4, IN2, IN3, IN1); // Note the sequence 4,2,3,1
void setup() {
step1.setSpeed(10);
}
void loop() {
step1.step(2048);
delay(1000);
step1.step(-2048);
delay(1000);
}
Execution Result