0% found this document useful (0 votes)
16 views

Bluetooth Controlled Robot

Uploaded by

jjjjhwyyhhbsh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Bluetooth Controlled Robot

Uploaded by

jjjjhwyyhhbsh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Bluetooth controlled Robot

Objective: Use wheeled robot kit and blue tooth module to control robot using smart phone.

Use Arduino board and motor shield and mount on chassis. Connect RX pin of BT module to A5 pin of
Arduino, and TX pin of BT to pin 4 of Arduino, instead of 1,and 0. Serial communication pins are
modified accordingly in the program.

Download a suitable app in the phone like Bluetooth RC controller.

Program is for doing forward, backward, left and right movement only. App support many other controls.

The app "Bluetooth RC Controller" send to the Bluetooth module the following commands:
Forward -> F
Back -> B
Left -> L
Right -> R
Forward Left -> G
Forward Right -> I
Back Left -> H
Back Right -> J
Stop -> S
Front Lights On -> W
Front Lights Off -> w
Back Lights On -> U
Back Lighst Off -> u
Horn On -> V
Horn Off -> v
Extra On -> X
Extra Off -> x
Speed 0 -> 0
Speed 10 -> 1
Speed 20 -> 2
Speed 30 -> 3
.
.
.
Speed 90 -> 9
Speed 100 -> q
Stop All -> D
In this project was used just the basic commands: Forward, Back, Left and Right.

Code

//This program is used to control a robot car using a app that communicates with Arduino trough a
bluetooth module

#include <AFMotor.h>

#include <SoftwareSerial.h>

SoftwareSerialMyBlue(A4, A5); //RX | TX define new tx rx pins on arduino

//creates two objects to control the terminal 3 and 4 of motor shield

AF_DCMotor motor1(3);

AF_DCMotor motor2(4);

char command;

void setup()

//Set the baud rate to your Bluetooth module.

MyBlue.begin(9600);

void loop()
{

if(MyBlue.available() > 0)

command = MyBlue.read();

Stop(); //initialize with motors stoped

//Change pin mode only if new command is different from previous.

switch(command)

case 'F':

forward();

break;

case 'B':

back();

break;

case 'L':

left();

break;

case 'R':

right();

break;

void forward()
{

motor1.setSpeed(255); //Define maximum velocity

motor1.run(FORWARD); //rotate the motor clockwise

motor2.setSpeed(255); //Define maximum velocity

motor2.run(FORWARD); //rotate the motor clockwise

void back()

motor1.setSpeed(255);

motor1.run(BACKWARD); //rotate the motor counterclockwise

motor2.setSpeed(255);

motor2.run(BACKWARD); //rotate the motor counterclockwise

void left()

motor1.setSpeed(255); //Define maximum velocity

motor1.run(FORWARD); //rotate the motor clockwise

motor2.setSpeed(0);

motor2.run(RELEASE); //turn motor2 off

void right()

motor1.setSpeed(0);

motor1.run(RELEASE); //turn motor1 off

motor2.setSpeed(255); //Define maximum velocity


motor2.run(FORWARD); //rotate the motor clockwise

void Stop()

motor1.setSpeed(0);

motor2.run(RELEASE); //turn motor1 off

motor2.setSpeed(0);

motor2.run(RELEASE); //turn motor2 off

You might also like