Android Controlled Robot: The Best Arduino Tutorial
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?
- Arduino / Arduino Clone or make your own custom arduino board with this tutorial.
- Two continuous rotation servo motors like this : Continuous rotation servo
- A 5v TTL -UART bluetooth module like : JY-MCU BT_BOARD (Cheaper) or Bluesmirf Gold/Silver
- A ball caster : Ball caster
- Two robot wheels like this, select wheels after checking if they fit in the servo : Robot wheels
- Chassis , usually a small acrylic board will do.
- Four AA duracell batteries and battery holder.
- Arduino IDE : Arduino
- 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 :
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 :
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 :
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 . Download the following arduino code for the project from : RCcar_DIYhacking. 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 :
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.
The demo video of the android controlled robot in action , please mind the application UI as it was a previous version, check it out and have fun with your android controlled robot!