Arduino UNO Controlled Stepper Motor System with Driver Integration
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit involves an Arduino UNO microcontroller, a 28BYJ-48 stepper motor, and a stepper motor driver. The Arduino UNO controls the stepper motor through the stepper motor driver, enabling precise control of the motor's rotation.
Component List
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
28BYJ-48 Stepper Motor
- Description: A small, inexpensive stepper motor commonly used in various applications.
- Pins: BLUE, PINK, YELLOW, ORANGE, RED
Stepper Motor Driver
- Description: A driver module used to control the stepper motor.
- Pins: ENA -, ENA +, DIR -, DIR+, PUL -, PUL +, B-, B+, A-, A+, GND, VCC
Wiring Details
Arduino UNO
- 5V: Connected to ENA + of the Stepper Motor Driver
- GND: Connected to DIR -, ENA -, and PUL - of the Stepper Motor Driver
- D9: Connected to PUL + of the Stepper Motor Driver
- D8: Connected to DIR+ of the Stepper Motor Driver
28BYJ-48 Stepper Motor
- BLUE: Connected to A- of the Stepper Motor Driver
- PINK: Connected to A+ of the Stepper Motor Driver
- YELLOW: Connected to B- of the Stepper Motor Driver
- ORANGE: Connected to B+ of the Stepper Motor Driver
- RED: Connected to VCC of the Stepper Motor Driver
Stepper Motor Driver
- ENA +: Connected to 5V of the Arduino UNO
- DIR -: Connected to GND of the Arduino UNO
- ENA -: Connected to GND of the Arduino UNO
- PUL -: Connected to GND of the Arduino UNO
- PUL +: Connected to D9 of the Arduino UNO
- DIR+: Connected to D8 of the Arduino UNO
- A-: Connected to BLUE of the 28BYJ-48 Stepper Motor
- A+: Connected to PINK of the 28BYJ-48 Stepper Motor
- B-: Connected to YELLOW of the 28BYJ-48 Stepper Motor
- B+: Connected to ORANGE of the 28BYJ-48 Stepper Motor
- VCC: Connected to RED of the 28BYJ-48 Stepper Motor
Code Documentation
Arduino UNO Code
#define IN1_PIN 8
#define IN2_PIN 9
#define IN3_PIN 10
#define IN4_PIN 11
void setup() {
pinMode(IN1_PIN, OUTPUT);
pinMode(IN2_PIN, OUTPUT);
pinMode(IN3_PIN, OUTPUT);
pinMode(IN4_PIN, OUTPUT);
}
void loop() {
// Rotate in one direction
stepMotor(1);
delay(1000);
// Rotate in the other direction
stepMotor(0);
delay(1000);
}
void stepMotor(int direction) {
int steps[8][4] = {
{1, 0, 0, 0}, // Step 1
{1, 1, 0, 0}, // Step 2
{0, 1, 0, 0}, // Step 3
{0, 1, 1, 0}, // Step 4
{0, 0, 1, 0}, // Step 5
{0, 0, 1, 1}, // Step 6
{0, 0, 0, 1}, // Step 7
{1, 0, 0, 1} // Step 8
};
if (direction == 1) {
for (int i = 0; i < 8; i++) {
digitalWrite(IN1_PIN, steps[i][0]);
digitalWrite(IN2_PIN, steps[i][1]);
digitalWrite(IN3_PIN, steps[i][2]);
digitalWrite(IN4_PIN, steps[i][3]);
delay(100); // Speed control
}
} else {
for (int i = 7; i >= 0; i--) {
digitalWrite(IN1_PIN, steps[i][0]);
digitalWrite(IN2_PIN, steps[i][1]);
digitalWrite(IN3_PIN, steps[i][2]);
digitalWrite(IN4_PIN, steps[i][3]);
delay(100); // Speed control
}
}
}
This code sets up the Arduino UNO to control the stepper motor through the stepper motor driver. The setup function initializes the pins as outputs, and the loop function alternates the motor's rotation direction every second. The stepMotor function handles the stepping sequence for the motor.