Android Controlled Robot: The Best Arduino Tutorial

 

Android 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 with this tutorial.
  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

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


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

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 . 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 :

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’ .

Android controlled robot

Discovering new bluetooth devices

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.

Android controlled robot

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 and have fun with your android controlled robot!

Recommended Posts
Showing 87 comments
  • zubair hasan
    Reply

    imma try it out

  • Abcd
    Reply

    I am using dc motor and i am not using a bread board .can you please send me a ciruit diagram and a pic of the connection made accordingly.

  • Akash kumar
    Reply

    can you please add otg control on the app so that via gamepad it can also be controlled

  • ishaan kharadkar
    Reply

    hey actually i am gonna use dc motors for the project and also a atmega8 arduino board so please give me the changes to be made in your code using L293D . please give me the code that will have the programme to use dc mottors

  • vignesh
    Reply

    anyone send a robot connecting a parts video link

  • Kabir Manek
    Reply

    Will the same code work if I buy a digital servo motor? if not, what alterations do I make?

  • Walter
    Reply

    Excellent! worked the first time I tried it. I prefer the following for Stop. Made my day – thanks!
    if(int(val)==53)//Stop
    {
    left.writeMicroseconds(1500); // 1.5 ms stay still sig, pin 13
    right.writeMicroseconds(1500);
    }

  • AZVERN DIAS
    Reply

    CAN I ADD A FIRE SENSOR TO THIS TOO?

  • Carlos
    Reply

    Hi, I have a little problem because as soon as I power the arduino the servos begin working without any command. Any suggestions? Thanks.

  • Teja
    Reply

    Hi,

    When I click on FRONT using the DIY RC CAR app on my android phone (the app has installed successfully) … it just resets the app, i.e. is closes and starts the app, before closing it says “Unfortunately DIY RC CAR has closed”

    I am not able to see the FRONT or any other button work.

    Please suggest

    • Teja
      Reply

      Sorry, my bad,

      I did everything in a hurry, and forgot to type the name of my bluetooth device in the app. Everything works like a charm!!

      Absolutely wonderful tute! Thanks!

      Peace!

  • amal
    Reply

    Is there a way to send a signal to a Robot when phone charged(I think this is not relevant to this article)

  • kaushal
    Reply

    will this code work for STM32F4 discovery board ?
    or
    can i get the code for STM32F4Discovery board?

  • prachi
    Reply

    i want coding for android robot controls like forward reverse stop

  • Tapan
    Reply

    In the code the connections of the bluetooth pins are not mentioned .for example pinmode(tx,INPUT);int txpin=10 etc.
    Will the code work?

  • Callum
    Reply

    Can you tell me how big was the board you used for the chassis please

  • abcd
    Reply

    as soon as i click onany button , the app stops working!! need help.Also can i somehow add in voice recognition in this app? Please let me know asap!

  • ruksh
    Reply

    can we use geared dc motors instead of the servos

  • harsha
    Reply

    i used 2 dc gear motors of 12volts..my robot is working bt the problem is thst it is not running on the floor..if u lift it up the motors are running..but if you place it on ground they are not running..i used motor shield..and 9v battery to power motors and 2AA batteries to power up arduino..plzz solve this problem

  • Aadil
    Reply

    I use 4AA batteries to power this. When I connect to thr bluetooth, it didn’t work. I used servo motors for this. The servo motors didn’t rotate when I press the button in the app..but with usb power its working. .Please help me. .

  • aadil
    Reply

    I use 4AA batteries to power. When I connect to thr bluetooth, it didn’t work. I used servo motors for this. The servo motors didn’t rotate when I press the button in the app..but with usb power its working. .Please help me. .

  • salman Faris
    Reply

    Why you two type of batteries in the picture
    I built it but didn’t work
    didn’t on the ardunio and Bluetooth module
    is there is any other special power source needed for ardunio.

    In your picture .you use two batteries.one batter holder power source another one is 9v batter
    but in my projects I only used one power source
    that is 4AA battery holder .but
    didn’t work plz help me…
    :-P

    • Arvind Sanjeev
      Reply

      Does the bluetooth commands reach arduino? You can check by looking whether the RX light on the arduino board blinks when you push a button from the phone.

  • salman
    Reply

    sir
    plz send me the source code of android application

    plz….

    • Arvind Sanjeev
      Reply

      Please go through the tutorial, I have already shared it as a link.

  • favour
    Reply

    Hi, i installed the Bluetooth app on my phone, but it crashes b4 for it finish loading, do u know what might be wrong wiv it?
    please get back to me

    • Arvind Sanjeev
      Reply

      Which phone and android version are you running? I would recommend testing it on different phones too.

  • Rahul
    Reply

    Plz help me how to connect ardino with the motor driver to control the direction,plz send a diagrammatic representation plz……am not using a bread board

  • Sneha
    Reply

    Hey!! can i use two plastic gear motors instead of metal gear motors or servomotors? and is the coding same for all kind of motors??

    • Arvind Sanjeev
      Reply

      Definitely you can. Except for servo motors, the coding for normal DC motors would be the same, DC motors would also need motor drivers with arduino.

  • abhi
    Reply

    can we use any application which is readily available in play store..?

    • Arvind Sanjeev
      Reply

      Will need to check, you can anyways download the application from here.

  • Lan
    Reply

    Hi Arvind,

    thanks the article it’s very useful.
    However, I’m very beginner and just started to learn this.
    But one thing I cannot understand. How did you join the wires/cables with each other? With soldering? Or just stick them with duck tape?

    Thanks very much

    • Arvind Sanjeev
      Reply

      Twisting the strands together helps me gets thing done faster :)

  • Muthu
    Reply

    Hi arvind,
    I need the code for the same RC car using Atmega8? Can u help me with it?

    • Arvind Sanjeev
      Reply

      The arduino code is available here. You can upload its hex file to the chip.

      • Muthu
        Reply

        Will it work for an ATMEGA8 controller?

      • Muthu
        Reply

        And also i am not using a servo motor. i use a DC motor. so What are the changes to be made in the code? Can u please help.

        • Arvind Sanjeev
          Reply

          Hey, you can check arduino L293 interface tutorials and edit the code really easily.

  • Rohan
    Reply

    Hi..I tried to build a bluetooth controlled robot using aurdino..also downloaded tge android app u have suggested..I am using 2 geared DC motors and have programmed the Arudino accordingly…the program is working fine..but the robot takes only the first command given from the app…either front left right or back..and moves in that direction also successfully…but once robot starts moving any other button pressed from the DIY RC CAR app is not taken by the robot…the app displays a message telling that a connection coudnt be established with the robot..What should i do ? please help :) TIY :)

    • Arvind Sanjeev
      Reply

      Hi Rohan,
      Seems like after executing the first command, the BT loses connection with arduino. This might be because of current fluctuations caused by DC motor, thereby causing arduino to reset. Are you using an external battery and driver for running the motors?

      • Rohan
        Reply

        Thank You for the reply Arvind. Yes the BT is losing connection with the arduino after the first command. Yes i am using an external battery. A 9V DC battery. I have powered up the L293D H bridge motor driver circuit (a ready made circuit bought in the market) using the battery. The H bridge ready made board provides a 5V output. I am powering my arduino board and the BT using the 5V output from H bridge. What changes can be done ? Please suggest :)

        • Arvind Sanjeev
          Reply

          Use 4 AA batteries to power the motors, they supply higher current than 9V battery.

          • Rohan
            Reply

            Okay will make the changes and get back :)
            Thank you :)

          • Rohan
            Reply

            Four AA batteries would output around 6V only. I tried but the same problem persists. I even tried it using 6 AA batteries that give a 9V output. Should i instead use AAA batteries ? or any other alternative ? Pls suggest :)

            • Arvind Sanjeev
              Reply

              The batteries should directly power the motors, make sure that arduino is not supplying the power for the motors and check your connections.

  • Thomas Bedouret
    Reply

    Hi ;)
    I’m currently building a quadcopter controlled by a Raspberry Pi, whom remote will be an Android device. Almost everything is working fine, but I’m in trouble with the bluetooth part of the homemade app. How could I deal with it ? Is there a way to make it simply (I’m quite new to Android programmation) ?

    • Arvind Sanjeev
      Reply

      You can just use the app I have posted here :)

      • Thomas Bedouret
        Reply

        Thanks, but I didn’t understand everything in it, so I was unable to make it fit to my wishes. I must confess I used this [http://www.elecfreaks.com/677.html] to make it as I wanted, and it works perfectly. I’ll send you the .apk file if you want to, when the whole app is finished :)

        • Arvind Sanjeev
          Reply

          Awesome :) We would love to have your project posted here. My email is: ars@diyhacking.com

          • Thomas Bedouret
            Reply

            Actually it’s a school project, so I mustn’t describe it before the exam… See you in June ;)

  • Teja bvs
    Reply

    What is the maximum range of distance between the android phone and robot?

    • Arvind Sanjeev
      Reply

      About normal range of a bluetooth connection. 10 metres maybe.

      • Teja bvs
        Reply

        Can I get the source code of android application?

  • Md.Arifuzzaman
    Reply

    I am using 2 gear motors for this and l298 motor driver. How can I interface with my arduino uno? What changes do I need to make in the arduino code?

    • Arvind Sanjeev
      Reply

      Hey, you can edit this code to work with DC motors. You just need to supply logic HIGH signals to particular pins on l298 to control it, editing 2-3 lines of code should do. Check out this tutorial on interfacing arduino with l298: https://www.youtube.com/watch?v=1Q0ZwpycbzY

  • Jeyaprakash
    Reply

    can i use a single brushless dc motor for my real wheels and a servo motor to steer front wheels in my bot??

    • Arvind Sanjeev
      Reply

      Sure, you can :) Will have to use a geared DC motor preferably.

  • Gagandeep
    Reply

    I want to know can I control 7 servos with bluetooth….. If yes can you send me a diagrammatic representation of it…. I’m working on robotic arm

    • Arvind Sanjeev
      Reply

      Edit the code and use the same project, connect the other servos to other pins on the arduino.

  • salman
    Reply

    which ardinuo model are use to make this project
    the freedunio or other like ardinuo to use to make this project.
    plz help me
    i am goig to make this project

    • Arvind Sanjeev
      Reply

      Any one will work. Freeduinos are cheaper than arduinos, no other significant differences.

  • luis noboa
    Reply

    when I run your application on my android this is stopped

    • Arvind Sanjeev
      Reply

      Which android version do you have on the phone. Did you turn ON the BT before opening the application and paired the module with it?

  • Kamal C K
    Reply

    Which application you used to develop the Android application. Android Studio or Eclipse?

  • rana
    Reply

    hii i just started to do this but i am using a motor driver can u please send me how to connect the circuit for the audrino and motor driver..please help me i am only one day left for my project please help me

  • suhail
    Reply

    I buy one similar to ardzino uno, and I festly plugged In to compuet and write the code but a confusion that even i want to press the reset button before uploading the programm,of I press restart button it will delete the current bootloader if any prblm when iam press reset even it is working a programm

    • Arvind Sanjeev
      Reply

      Pressing the reset will not cause any problems, it only resets the current program. Try experimenting first.

  • suhail
    Reply

    Unfortunatly iam a biginer to aurdino iam doesnt tried it befor
    Even it is costly becuase iam a student
    Bca 1st year even i want to buy one I want to go thrichur from malappurram

    CAN I USE FREEDUINO INSTEAD OF AURDINO PLS HELP ME

    • Arvind Sanjeev
      Reply

      Yes, freeduino is the best alternative. There is practically no difference other than in appearance between the two.

  • suhail
    Reply

    Your idea is great but iam planning to make a hex keypad

  • suhail
    Reply

    Hey aravind sanjeev
    Dude if we make an digital code lock using aurdino with lcd too

    • Arvind Sanjeev
      Reply

      Hi Suhail, thats a cool idea. Are you planning to use the android phone for entering the code?

  • kazuma
    Reply

    wow thanks. I`m already works at it and already buy few part like arduino,motor driver ld9110 because the clerk said it more better well idk,a breadboard,the motor I just use from my Tamiya car because I don`t have any money more left because the motor I want too use cost the same price from previous part I buy each,the Bluetooth thing too because they don`t have it.well I just work at it some time in future.well anyways I try to learn coding for now.anyways thank for instruction.btw do I need thing called relad or power resistor because clerk said to keep the chip from black out..?

    • Arvind Sanjeev
      Reply

      Hello Kazuma,
      You can always buy stuff cheaply online, and you don’t have to use any other peripherals apart from the motor driver for running the motors.

      • kazuma
        Reply

        At last I completed my first robot,Bluetooth controlled and human following system.hell idk how come it escaleted they much

  • kazuma
    Reply

    I presume Bluetooth software still work the same.do I need to add more programme for arduino or there is more better option

    • Arvind Sanjeev
      Reply

      Everything works the same, you just need to interface the motor driver to arduino. Check out arduino L293D tutorials online. The software only has to be edited for controlling the geared motors.

  • kazuma
    Reply

    can I use gear motor for this project to carry more heavy thing is it the same as servo motor

    • Arvind Sanjeev
      Reply

      Yes, you definitely can use one. But, you will have to use a motor driver (L293D) to control it (direction of movement: clockwise or anti clockwise).

pingbacks / trackbacks

Leave a Comment

91 − 84 =

Start typing and press Enter to search