ARDUINO PROJECT-3: ANDROID PHONE CONTROLLED ROBOT

Android controlled robot

Ever wanted to make an android controlled robot or car? Control your RC car with a smartphone? Or wanted a tutorial about connected devices and getting started with it? Now you can do that with this simple DIY hack that even provides you with a free android application, thus it doesn’t require you to have any experience in android application programming. Download the free application to your phone and start controlling your robot. Have fun with this DIY hacking tutorial!

What are the stuff required to do this project? Hardware :

  1. Arduino / Arduino Clone or make your own custom arduino board
  2. Two continuous rotation servo motors like this : Continuous rotation servo
  3. A 5v TTL -UART bluetooth module like : JY-MCU BT_BOARD (Cheaper) or Bluesmirf Gold/Silver
  4. A ball caster : Ball caster
  5. Two robot wheels like this, select wheels after checking if they fit in the servo : Robot wheels
  6. Chassis , usually a small acrylic board will do.
  7. Four AA duracell batteries and battery holder.

Software :

  1. Arduino IDE : Arduino
  2. Eclipse for android programming (optional, not required). For instructions on installing and setting up the environment : How to install android and eclipse and tutorials to begin learning android programming even though you don’t require it for this project : Tutorial .

So how does it work?

The android application controlled robot communicates via bluetooth to the bluetooth module present on the robot. While pressing each button on the application, corresponding commands are sent via bluetooth to the robot. The commands that are sent are in the form of ASCII. The arduino on the robot then checks the command received with it’s previously defined commands and controls the servo motors depending on the command received to cause it to move forward, backward, left, right or to stop. Thus allowing us to create an android controlled robot.  Basic block diagram :

Android controlled robot

Step 1- Assembling the components for the android controlled robot

Take the piece of acrylic board and stick the servo motors to the left and right edges using hotglue/super glue. Then attach the ball caster. On the top side, stick the arduino board using double side tape, do the same for the battery holder. This is how it looks like :

Android Controlled Robot

Android Controlled Robot

Step 2 – Setting up the connections for the android controlled robot

Setup the hardware connections with the arduino and the servo motors. The continuous rotation servo motors are those kinds of servo motors that cannot be controlled or set at a particular angle unlike normal servos. Servos have three wires coming from them : Red- Power , Black -Ground, White/Yellow- PWM /PPM Signal. The left servo motor (white/yellow wire) is hooked up to arduino digital pin 9 and right servo motor (white/yellow wire) to arduino digital pin 10. The black wires of both the motors are connected to arduino GND and the Red wires to the positive terminal of the battery holder. Connect the RX pin of bluetooth module to TX pin (digital pin 1) of arduino and TX pin of module to RX pin of arduino (pin 0). Connect Vcc and Gnd of module to the arduino. Connect the negative terminal of battery holder to arduino GND. The connections will look like this :

Arduino Android controlled robot

Step 3- Loading the arduino software for the android controlled robot

If you are new to arduino, download the arduino IDE (Integrated Development Environment) from Arduino .

/*The following is the code required to be run on arduino to enable control from 
a smartphone, please install RCcar android application first on your android phone.
Please visit DIYhacking.com for detailed instructions on this project.*/

/*This project requires 2 continous rotation servos connected to pins 9 and 10 of arduino*/ 


#include <Servo.h>
Servo left;//Define left servo
Servo right;//Define right servo
byte val;



void setup()
{
  Serial.begin(115200);//Change the baud rate value depending on the default baud rate of your bluetooth module, for Bluesmirf-115200 and for JY-MCU-9600
  left.attach(9, 800, 2200); //left servo on digital pin 9 of arduino
  right.attach(10, 800, 2200); //right servo on digital pin 10 of arduino
  
}

void loop()
{
 int a=0;
 if(Serial.available())
  {
    val=Serial.read();
    Serial.println(int(val));

if(int(val)==49)//Move front
{
  right.write(180);//Rotates servo clockwise
  left.write(0);//Rotates servo anticlockwise
}

if(int(val)==50)//Move back
{
  right.write(0);
  left.write(180);
}

if(int(val)==53)//Stop
{
  right.write(90);//Stops the servos
  left.write(90);//Stops the servos
}

if(int(val)==51)//left
{
  right.write(180);
  left.write(90);
}

if(int(val)==52)//right
{
  right.write(90);
  left.write(0);
}


if(int(val)==55)//Extra button
{
  //Enter your code for any extra commands
}

}
}



Upload the code to the arduino. PLEASE NOTE : SINCE THE BLUETOOTH MODULE IS CONNECTED TO THE RX AND TX PINS OF THE ARDUINO, THE MODULE SHOULD BE REMOVED WHILE UPLOADING THE CODE FROM PC TO THE ARDUINO. THE MODULE SHOULD BE CONNECTED ONCE THE UPLOAD IS COMPLETE. The code uses the arduino servo library and simple commands. Servo is controlled using commands like : servo.write(90) -> stops the servo , servo.write(180) ->rotates servo clockwise and servo.write(0)-> rotates servo anti-clockwise. Screenshot of arduino code :

Arduino code

Step 4- Downloading the android application and setting up the bluetooth

To download the android application to your phone, copy this .apk file to your phone from the PC and then click on it from the phone to install it : DIY RC car. For those who wish to modify the application, I am attaching the project file here : DIY RC car project . Be sure, to check “Allow installation of non-Market apps” in the Security tab under settings. Once you have installed the application, before opening it you need to pair and connect with your bluetooth module. For this, you need to power the arduino and bluetooth module and then turn ON the bluetooth of your phone and make it visible to other devices. After that, search for new devices in bluetooth, select your bluetooth module from the list, enter the pairing code when prompted , it is usually ‘1234’  or ‘0000’ .

Note the name of your device , in this case it is “HC-06″. After pairing with the robot, go to the “DIY RC car” application and enter the name of your bluetooth module you noted earlier (case-sensitive) and click “OK”. After that the phone will get connected to your robot , and on clicking the respective buttons, the robot will move accordingly.

DIY RC car application

The demo video of the android controlled robot in action , please mind the application UI as it was a previous version, check it out:

courtesy:http://diyhacking.com/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s