This article helps you to make a robot that can be controlled from your android powered mobile through Bluetooth.
HC-05:
This Bluetooth module works on SPP (serial port profile). It establishes a serial communication(UART) between your android mobile and microcontroller.
This module works in two modes:
1) AT mode
2)COM mode
AT mode:
In AT mode you can directly connect the module to your computer hyper terminal or any other serial gate way through DB9 serial port through MAX232 circuit (or you can use any USB to UART gateways like FT232and configure through AT commands. set the baud rate "38400"
some example commands:
AT <enter> it gives the response OK continuously so press <enter> again to stop
AT+NAME? <enter> it displays the name of Bluetooth module
AT+NAME=new_name <enter> changes module name to "new_name"
AT+PSWD? <enter> displays password to enter while pairing with this device
AT+PSWD=4321 changes the password to 4321 ( only 4 digit number is accepted as password )
for more info regarding AT commands refer to the data sheet.
COM mode:
this is the mode that to be set when interfacing with a microcontroller through UART.
In this project i'm using an Arduino MEGA 2560 and a Bluetooth shield from Robogenesis
To drive the DC motors i'm using L293D.
//--------------- code starts-------------------------
//---------------------------------------------------
unsigned char blue_data;
void setup()
{
Serial.begin(9600);// set up serial communications with 9600 baud rate
pinMode(7, OUTPUT);//motor 1a
pinMode(6, OUTPUT);//motor 1b
pinMode(5, OUTPUT);//motor 2a
pinMode(4, OUTPUT);//motor 2b
digitalWrite(7,LOW);
digitalWrite(6,LOW);
digitalWrite(5,LOW);
digitalWrite(4,LOW);
}
void loop()
{
if (Serial.available() > 0)
{
blue_data = Serial.read();// get incoming byte from bluetooth
if(blue_data=='F' )//forword
{
digitalWrite(7,HIGH);digitalWrite(6,LOW);digitalWrite(5,HIGH);digitalWrite(4,LOW);
}
else if(blue_data=='B' )//backword
{
digitalWrite(7,LOW);digitalWrite(6,HIGH);digitalWrite(5,LOW);digitalWrite(4,HIGH);
}
else if(blue_data=='L' )//left turn
{
digitalWrite(7,LOW);digitalWrite(6,HIGH);digitalWrite(5,HIGH);digitalWrite(4,LOW);
}
else if(blue_data=='R' )// right turn
{
digitalWrite(7,HIGH);digitalWrite(6,LOW);digitalWrite(5,LOW);digitalWrite(4,HIGH);
}
else if(blue_data=='S' )// stop
{
digitalWrite(7,LOW);digitalWrite(6,LOW);digitalWrite(5,LOW);digitalWrite(4,LOW);
}
}
}
This module works in two modes:
1) AT mode
2)COM mode
AT mode:
In AT mode you can directly connect the module to your computer hyper terminal or any other serial gate way through DB9 serial port through MAX232 circuit (or you can use any USB to UART gateways like FT232and configure through AT commands. set the baud rate "38400"
some example commands:
AT <enter> it gives the response OK continuously so press <enter> again to stop
AT+NAME? <enter> it displays the name of Bluetooth module
AT+NAME=new_name <enter> changes module name to "new_name"
AT+PSWD? <enter> displays password to enter while pairing with this device
AT+PSWD=4321 changes the password to 4321 ( only 4 digit number is accepted as password )
for more info regarding AT commands refer to the data sheet.
COM mode:
this is the mode that to be set when interfacing with a microcontroller through UART.
In this project i'm using an Arduino MEGA 2560 and a Bluetooth shield from Robogenesis
To drive the DC motors i'm using L293D.
CIRCUIT DIAGRAM:
arduino code:
//---------------------------------------------------//--------------- code starts-------------------------
//---------------------------------------------------
unsigned char blue_data;
void setup()
{
Serial.begin(9600);// set up serial communications with 9600 baud rate
pinMode(7, OUTPUT);//motor 1a
pinMode(6, OUTPUT);//motor 1b
pinMode(5, OUTPUT);//motor 2a
pinMode(4, OUTPUT);//motor 2b
digitalWrite(7,LOW);
digitalWrite(6,LOW);
digitalWrite(5,LOW);
digitalWrite(4,LOW);
}
void loop()
{
if (Serial.available() > 0)
{
blue_data = Serial.read();// get incoming byte from bluetooth
if(blue_data=='F' )//forword
{
digitalWrite(7,HIGH);digitalWrite(6,LOW);digitalWrite(5,HIGH);digitalWrite(4,LOW);
}
else if(blue_data=='B' )//backword
{
digitalWrite(7,LOW);digitalWrite(6,HIGH);digitalWrite(5,LOW);digitalWrite(4,HIGH);
}
else if(blue_data=='L' )//left turn
{
digitalWrite(7,LOW);digitalWrite(6,HIGH);digitalWrite(5,HIGH);digitalWrite(4,LOW);
}
else if(blue_data=='R' )// right turn
{
digitalWrite(7,HIGH);digitalWrite(6,LOW);digitalWrite(5,LOW);digitalWrite(4,HIGH);
}
else if(blue_data=='S' )// stop
{
digitalWrite(7,LOW);digitalWrite(6,LOW);digitalWrite(5,LOW);digitalWrite(4,LOW);
}
}
}
android app:
Description
This comment has been removed by a blog administrator.
ReplyDeletewhere can i get that app
ReplyDeletePlay store
Delete