This circuit is designed to control two 28BYJ-48 stepper motors using an Arduino UNO microcontroller and two ULN2003A breakout boards. The circuit also includes an HC-06 Bluetooth module for wireless communication, allowing the motors to be controlled via Bluetooth commands. The Arduino UNO is programmed to interpret the Bluetooth commands and drive the stepper motors accordingly.
5V
and GND
are used to power the ULN2003A breakout boards3.3V
and GND
are used to power the HC-06 Bluetooth moduleD4
to D11
are used to send control signals to the ULN2003A breakout boardsD0
(RX) and D1
(TX) are used for serial communication with the HC-06 Bluetooth moduleBLUE
, PINK
, YELLOW
, ORANGE
, and RED
wiresVCC
connected to 3.3V
on the Arduino UNOGND
connected to GND
on the Arduino UNORXD
connected to D1
(TX) on the Arduino UNOTXD
connected to D0
(RX) on the Arduino UNO+5V
connected to 5V
on the Arduino UNO0V
connected to GND
on the Arduino UNOIn 1
to In 4
connected to digital pins D4
to D11
on the Arduino UNO (two boards, each connected to its respective set of pins)BLUE wire
, PINK wire
, YELLOW wire
, ORANGE wire
, and RED wire
connected to the corresponding wires of the 28BYJ-48 stepper motors#include <AccelStepper.h>
// Define the pins for motor 1
AccelStepper motor1(AccelStepper::HALF4WIRE, 8, 10, 9, 11);
// Define the pins for motor 2
AccelStepper motor2(AccelStepper::HALF4WIRE, 4, 6, 5, 7);
// Set initial rotation speed
const int rotationSpeed = 500;
void setup() {
// Set up the serial communication for Bluetooth
Serial.begin(9600);
motor1.setMaxSpeed(rotationSpeed);
motor1.setAcceleration(500);
motor1.setCurrentPosition(0);
motor2.setMaxSpeed(rotationSpeed);
motor2.setAcceleration(500);
motor2.setCurrentPosition(0);
}
void loop() {
// Check if data is available from the Bluetooth app
if (Serial.available() > 0) {
char command = Serial.read();
// Write commands for the app
switch (command) {
case 'F': // Start both motors rotating forward
motor1.setSpeed(rotationSpeed);
motor2.setSpeed(rotationSpeed);
motor1.enableOutputs();
motor2.enableOutputs();
break;
case 'B': // Start both motors rotating backward
motor1.setSpeed(-rotationSpeed);
motor2.setSpeed(-rotationSpeed);
motor1.enableOutputs();
motor2.enableOutputs();
break;
case 'S': // Stop and disconnect both motors
motor1.setSpeed(0); // Set speed to 0 to stop immediately
motor2.setSpeed(0); // Set speed to 0 to stop immediately
motor1.disableOutputs(); // Disable outputs to disconnect motors
motor2.disableOutputs(); // Disable outputs to disconnect motors
break;
default:
// Ignore any other commands
break;
}
}
// Run motors
motor1.runSpeed();
motor2.runSpeed();
}
The code above is written for the Arduino UNO and is responsible for controlling two stepper motors via the ULN2003A breakout boards. It includes a Bluetooth communication setup to receive commands and control the motors accordingly. The AccelStepper
library is used to facilitate the control of the stepper motors.