Bluetooth controlled robot
controlling a basic robot using a Bluetooth enabled mobile
STEP 1: MATERIALS NEEDED
1. Bread board
2. HC-05 Bluetooth module
3. jumper wires or breadboard wires
4. Induino R3 or any arduino clone
5. two 500 rpm motor
6. two 9v batteries
7. L293D
8. Chassis
9. Wheels
10. Android mobile
2. HC-05 Bluetooth module
3. jumper wires or breadboard wires
4. Induino R3 or any arduino clone
5. two 500 rpm motor
6. two 9v batteries
7. L293D
8. Chassis
9. Wheels
10. Android mobile
you can buy chassis, wheels, motors as per your budget....
STEP 2: BREADBOARD CONNECTION
connect the breadboard in this way way so that 5v flows through the
outer side and gnd through the inner horizontal connection. connect the
5v and gnd to the breadboard from the induino.
The applied 5v should pass in this order ABCD
The applied 5v should pass in this order ABCD
STEP 3: CONNECTING HC-05
connect the Vcc to 5v and gnd to ground... connect the rx of hc-05 to
the tx of the induino and connect the tx of the hc-05 to the rx of the
induino... key and state need not be connected.
STEP 4: L293D
connect the pins 4,5,12,13 of L293D to ground and connect O1, O2 to left motor, similarly O3,O4 to right motor,
i1-pin2 of induino
i2-pin4 of induino
i3-pin12 of induino
i4-pin11 of induino
i1-pin2 of induino
i2-pin4 of induino
i3-pin12 of induino
i4-pin11 of induino
STEP 5: MOTOR CONNECTIONS
after connecting motor it will look like this...
if you want connect a buzzer to pin8 of induino which will act as horn...
STEP 6: CODE
#include <SoftwareSerial.h>
#define BIB 3
#define BIA 5
#define AIB 6
#define AIA 9
//PWM CONTROL SPEED
int speed1 = 0; // PWM controll speed
// for incoming serial data
SoftwareSerial bluetooth(0,1); // RX, TX
int BluetoothData;
void setup()
{
bluetooth.begin(9600);
Serial.begin(9600);
pinMode(BIB,OUTPUT); // left motor B
pinMode(BIA,OUTPUT); // left motor A
pinMode(AIB,OUTPUT); // right motor B
pinMode(AIA,OUTPUT); // right motor A
}
void loop()
{
int i,j;
if (bluetooth.available()>0)
{
BluetoothData=bluetooth.read();
Serial.println(BluetoothData);
}
switch(BluetoothData)
{
case 'F': // control to stop the robot
forward();
break;
case 'I': //control for right
fright();
break;
case 'G': //control for left
fleft();
break;
case 'S': //control for stop
stop();
break;
case 'B': //control for backward
reverse();
break;
case 'H':
bleft();
break;
case 'J':
bright();
break;
case 'L':
left();
break;
case 'R':
right();
analogWrite(BIA, speed1);
analogWrite(AIA, speed1);
break;
case '0': // PWM speed values
speed1 = 0 ;
break;
case '1':
speed1 = 51;
break;
case '2':
speed1 = 60;
break;
case '3':
speed1 = 66;
break;
case '4':
speed1 = 80;
break;
case '5':
speed1 = 101;
break;
case '6':
speed1 = 120;
break;
case '7':
speed1 = 157;
break;
case '8':
speed1 = 200;
break;
case '9':
speed1 = 224;
break;
case 'q':
speed1 = 255;
break;
}
}
void forward()
{
analogWrite(BIB,0);
analogWrite(BIA,speed1);
analogWrite(AIB,speed1);
analogWrite(AIA,0);
}
void stop()
{
//LEFT WHEEL STOPPED
analogWrite(BIB,0);
analogWrite(BIA,0);
//RIGHT WHEEL STOPPED
analogWrite(AIB,0);
analogWrite(AIA,0);
}
void reverse()
{
//LEFT WHEEL REVERESE
analogWrite(BIB,speed1);
analogWrite(BIA,0);
//RIGHT WHEEL REVERSE
analogWrite(AIB,0);
analogWrite(AIA,speed1);
}
void fleft()
{
//LEFT WHEEL STOPPED
analogWrite(BIB,1);
analogWrite(BIA,1);
//RIGHT WHEEL FORWARD
analogWrite(AIB,1);
analogWrite(AIA,0);
}
void left()
{
//LEFT WHEEL STOPPED
analogWrite(BIB,1);
analogWrite(BIA,0);
//RIGHT WHEEL FORWARD
analogWrite(AIB,1);
analogWrite(AIA,0);
}
void fright()
{
//LEFT WHEEL FORWARD
analogWrite(BIB,0);
analogWrite(BIA,1);
//RIGHT WHEEL STOPPED
analogWrite(AIB,1);
analogWrite(AIA,1);
}
void right()
{
analogWrite(BIB,0);
analogWrite(BIA,1);
analogWrite(AIB,0);
analogWrite(AIA,1);
}
void bleft()
{
//LEFT WHEEL STOPPED
analogWrite(BIB,1);
analogWrite(BIA,0);
//RIGHT WHEEL FORWARD
analogWrite(AIB,1);
analogWrite(AIA,1);
}
void bright()
{
//LEFT WHEEL FORWARD
analogWrite(BIB,1);
analogWrite(BIA,1);
//RIGHT WHEEL STOPPED
analogWrite(AIB,0);
analogWrite(AIA,1);
}
The pin declaration in the code will vary, edit and upload this code to
induino or any arduino board.... Please change the pins according to
the your connections
STEP 7: CONNECTING WITH BLUETOOTH
Download this app from play store..
connect a 9v battery to induino.. the Bluetooth module will start to blink continuously.... now open the app in your mobile
1.At first a red light will blink at the left top of the app
2. go to options and click connect
3. connect to the Bluetooth device.... default pin is 1234 or 0000
4. after connecting there will be green light in the left top corner of the app
2. go to options and click connect
3. connect to the Bluetooth device.... default pin is 1234 or 0000
4. after connecting there will be green light in the left top corner of the app
that's it now you can enjoy your own Bluetooth RC robot
there may be some mistakes.. tell me if you find any ^_^
Comments
Post a Comment