Introduction
A Bluetooth controlled robot is a versatile project that combines wireless communication and robotics. Using the 8051 microcontroller, this project demonstrates how to control a robot's movement via Bluetooth commands sent from a smartphone. The robot can move forward, backward, left, and right based on the received commands. This project is ideal for learning about wireless communication, motor control, and microcontroller programming.
Components Required
8051 Microcontroller (e.g., AT89S52)
HC-05 Bluetooth Module
L293D Motor Driver IC
DC Motors (2 units)
Robot Chassis
Wheels and Castor Wheel
Power Supply (Battery Pack, 12V for motors, 5V for 8051 and Bluetooth module)
Resistors (10kΩ, 1kΩ)
Capacitors (33pF, 100μF)
Crystal Oscillator (11.0592 MHz)
Breadboard and Connecting Wires
Circuit Diagram
The 8051 microcontroller interfaces with the HC-05 Bluetooth module for wireless communication and the L293D motor driver to control the DC motors.
+5V ----- +5V
|
|
HC-05
+---+
+5V |VCC|
GND |GND|
TX |TXD|------- RXD (P3.0 of 8051)
RX |RXD|------- TXD (P3.1 of 8051)
+---+
L293D Motor Driver
+---+
1,9 | VCC2 | ----- 12V (Motor Power Supply)
8,16 | VCC1 | ----- +5V
4,5,12,13 | GND | ----- Ground
2 | IN1 | ----- P2.0 (8051)
7 | IN2 | ----- P2.1 (8051)
10 | IN3 | ----- P2.2 (8051)
15 | IN4 | ----- P2.3 (8051)
3 | OUT1| ----- Motor 1
6 | OUT2| ----- Motor 1
11 | OUT3| ----- Motor 2
14 | OUT4| ----- Motor 2
+---+
DC Motors
Motor 1 - Connected to OUT1 and OUT2 of L293D
Motor 2 - Connected to OUT3 and OUT4 of L293D
Pin Connections
HC-05 Bluetooth Module:
VCC to +5V
GND to Ground
TXD to RXD (P3.0 of 8051)
RXD to TXD (P3.1 of 8051)
L293D Motor Driver IC:
VCC2 to 12V (Motor Power Supply)
VCC1 to +5V
GND to Ground
IN1 to P2.0 of 8051
IN2 to P2.1 of 8051
IN3 to P2.2 of 8051
IN4 to P2.3 of 8051
OUT1 and OUT2 to Motor 1
OUT3 and OUT4 to Motor 2
Software Implementation
The code is written in C using Keil uVision IDE. It involves initializing the UART for Bluetooth communication, reading commands from the Bluetooth module, and controlling the motors based on these commands.
#include <reg51.h>
sbit IN1 = P2^0; // Motor 1 IN1
sbit IN2 = P2^1; // Motor 1 IN2
sbit IN3 = P2^2; // Motor 2 IN3
sbit IN4 = P2^3; // Motor 2 IN4
void delay(unsigned int count) {
int i, j;
for(i=0; i<count; i++)
for(j=0; j<1275; j++);
}
void uart_init(void) {
TMOD = 0x20; // Timer1 in mode 2
TH1 = 0xFD; // Baud rate 9600
SCON = 0x50; // 8-bit data, 1 stop bit, REN enabled
TR1 = 1; // Start Timer1
}
char uart_receive(void) {
while(RI == 0); // Wait for reception to complete
RI = 0; // Clear reception interrupt flag
return SBUF; // Return received character
}
void move_forward() {
IN1 = 1; IN2 = 0;
IN3 = 1; IN4 = 0;
}
void move_backward() {
IN1 = 0; IN2 = 1;
IN3 = 0; IN4 = 1;
}
void turn_left() {
IN1 = 0; IN2 = 1;
IN3 = 1; IN4 = 0;
}
void turn_right() {
IN1 = 1; IN2 = 0;
IN3 = 0; IN4 = 1;
}
void stop() {
IN1 = 0; IN2 = 0;
IN3 = 0; IN4 = 0;
}
void main() {
char command;
uart_init(); // Initialize UART
while(1) {
command = uart_receive(); // Receive command from Bluetooth
switch(command) {
case 'F': // Forward
move_forward();
break;
case 'B': // Backward
move_backward();
break;
case 'L': // Left
turn_left();
break;
case 'R': // Right
turn_right();
break;
case 'S': // Stop
stop();
break;
default:
stop();
break;
}
delay(100); // Small delay for motor control
}
}
Explanation
Initialization:
UART Initialization: The uart_init() function configures the UART for Bluetooth communication at a baud rate of 9600.
Receiving Commands:
The uart_receive() function waits for and reads a character from the Bluetooth module via UART.
Motor Control:
Functions like move_forward(), move_backward(), turn_left(), turn_right(), and stop() control the direction of the motors based on the received commands.
Command Processing:
The main loop continuously receives commands and uses a switch-case structure to call the appropriate motor control function based on the command received.
Conclusion
This project demonstrates the use of the 8051 microcontroller to create a Bluetooth controlled robot. The system can receive commands from a smartphone via a Bluetooth module and control the robot's movement accordingly. This project is a great way to learn about wireless communication, motor control, and using microcontrollers in robotics applications.
Want us to guide you through your project or make the project for you ?
Create Various Projects
Check out our Free Arduino Projects Playlist - Arduino Projects
Check out our Free Raspberry Pi Projects Playlist - Raspberry Pi Projects
Check out our Free TinkerCAD Projects Playlist - TinkerCAD Projects
Check out our Free IoT Projects Playlist - IoT Projects
Check out our Free Home Automation Projects Playlist - Home Automation Projects
Check out our Free NodeMCu Projects Playlist - NodeMCu Projects
Commentaires