Arduino-Controlled Dual Stepper Motor System with Bluetooth Interface
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
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.
Component List
Arduino UNO
- Microcontroller board based on the ATmega328P
- It has 14 digital input/output pins, 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header, and a reset button.
28BYJ-48 Stepper Motor (x2)
- A small, 5-line, 4-phase stepper motor
- Can be driven by ULN2003A breakout board
HC-06
- A Bluetooth module that allows for wireless communication
- Operates at 3.3V and has RXD and TXD pins for serial communication
ULN2003A Breakout Board (x2)
- A board with a ULN2003A driver chip that can drive up to 7 inputs
- Used to amplify the control signals from the Arduino to drive the stepper motors
Wiring Details
Arduino UNO
5VandGNDare used to power the ULN2003A breakout boards3.3VandGNDare used to power the HC-06 Bluetooth module- Digital pins
D4toD11are used to send control signals to the ULN2003A breakout boards - Digital pins
D0(RX) andD1(TX) are used for serial communication with the HC-06 Bluetooth module
28BYJ-48 Stepper Motor
- Each motor is connected to a ULN2003A breakout board via its
BLUE,PINK,YELLOW,ORANGE, andREDwires
HC-06
VCCconnected to3.3Von the Arduino UNOGNDconnected toGNDon the Arduino UNORXDconnected toD1(TX) on the Arduino UNOTXDconnected toD0(RX) on the Arduino UNO
ULN2003A Breakout Board
+5Vconnected to5Von the Arduino UNO0Vconnected toGNDon the Arduino UNOIn 1toIn 4connected to digital pinsD4toD11on the Arduino UNO (two boards, each connected to its respective set of pins)BLUE wire,PINK wire,YELLOW wire,ORANGE wire, andRED wireconnected to the corresponding wires of the 28BYJ-48 stepper motors
Documented Code
#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.