Arduino robot controlled from an Android phone via Bluetooth

By | January 25, 2014

Project overview

This is a differential steering robot that can be controlled from an Android phone via Bluetooth. The robot’s “brain” is Arduino Uno compatible board (an “Arduino on a breadboard”). The robot uses a JY-MCU Bluetooth module for communication with the Android phone. A custom Android app, created with the MIT App Inventor 2 essentially acts as a remote control, sending commands to the Arduino that tell the robot to move forward, reverse, stop or rotate.

The robot also has two ultrasonic sensors (one mounted on the front and one on the back) that are used for obstacle detection. If you try to drive the robot into a wall using your phone remote, the robot will overwrite that command and will stop when it detects an obstacle closer than 10 cm.

The communication between the phone and the Arduino board is very basic at the moment. When you press a button on the phone, it sends a byte over the Bluetooth connection (currently the numbers 0 to 5 are used). The Arduino sketch reads the data on the serial port and acts based on the command (0 is stop, 1 is move forward etc.). This can be easily extended and can go both ways. For example, we can easily display the data from the two ultrasonic distance sensor on the phone.

Parts list:

  • Arduino Uno (or compatible board)
  • JY-MCU Bluetooth Module
  • 2 Servos modified for continuous rotation
  • 2 HC-SR04 ultrasonic sensors for obstacle detection
  • Wheels (salvaged from a printer)
  • Acrylic base
  • 2 casters
  • Android phone
  • 9V battery with case for the Arduino
  • 5 AA batteries and case for the servos and other components
  • Screws, zip ties and some hot glue to keep it all together
  • Protoboard & wires to connect the electronic components
  • A couple of resistors used to make a voltage divider (shift down 5V signal from the Arduino to 3.3V)

Note: You may see a character LCD screen on the robot that is controlled from my “Arduino” through a shift register. Currently the LCD just shows the readings from the two ultrasonic sensors and is not needed for this application. It is just a side project / experiment to get an LCD salvaged from a trashed phone working with Arduino and I just used the same robot platform for the test.

Main Connections:

  • left servo signal to Arduino pin D2
  • right servo signal to Arduino pin D4
  • front HC-SR04 sensor echo and trigger pin connected to Arduino pin D6
  • back HC-SR04 sensor echo and trigger pin connected to Arduino pin D7
  • JY-MCU TX pin to the Arduino pin 12 (used as RX pin in SoftWareSerial)
  • JY-MCU RX pin through voltage divider and to the Arduino pin 9 (used as TX pin in SoftWareSerial)
  • all grounds connected together
  • HC-SR04 sensors and the JY-MCU are powered from regulted 5V line
  • the continuous rotation servos are powered from a 5 rechargeable AA battery pack


The Arduino sketch and the App Inventor 2 project file can be found on GitHub:

ArduinoBlueBot on GitHub

Disclaimer: This is a hobby for me and I am a noob. I am happy to share the code, as I learned from others who did the same, but you use it at your own risk.

The key components of the application have been already covered in earlier articles:

Update (January, 28th, 2014): Posted on the awesome “Let’s make robots” community:

22 thoughts on “Arduino robot controlled from an Android phone via Bluetooth

  1. Arduino Beginner

    Hye, I want to make a project like this but with using the accelerometer sensor built-in the android phone. I just wondering how the Arduino will read the data from the sensor? Is it in serial communication like this project or not? How about the programming?

    1. Stan Post author

      This should be easily doable, even with AppInventor. If you read the AI2 documentation on sensors, you can see how to read the data from the built in accelerometers on the phone. Maybe worth checking out the features of the Orientation sensor as well:

      Then you can send the raw data to Arduino, over the same BlueTooth connection using serial, or do some processing on the phone and send heading info only.

  2. Al B

    Nice work! We built a similar project. However, we installed an Android device onto a RC car and used an IOIO board instead to control it autonomously. Here is the preliminary result:

    1. Stan

      Very cool, and much more advanced that what I have here! Thanks for sharing your project! Here is the link to the write-up, for the benefit of other who stumble into this post:

      I dabbled a bit with OpenCV, but had trouble getting to work on my older smartphone. Got better results with the Raspberry PI. This is inspiring me to try again…

  3. Vatur

    I compiled the given arduino code but i got these errors:
    R:\arduino-1.0.5-r2\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::begin(long int)':
    R:\arduino-1.0.5-r2\libraries\SoftwareSerial\SoftwareSerial.cpp:399: error: 'PCICR' was not declared in this scope
    R:\arduino-1.0.5-r2\libraries\SoftwareSerial\SoftwareSerial.cpp:402: error: 'PCMSK2' was not declared in this scope
    R:\arduino-1.0.5-r2\libraries\SoftwareSerial\SoftwareSerial.cpp:402: error: 'PCMSK0' was not declared in this scope
    R:\arduino-1.0.5-r2\libraries\SoftwareSerial\SoftwareSerial.cpp:402: error: 'PCMSK1' was not declared in this scope
    R:\arduino-1.0.5-r2\libraries\SoftwareSerial\SoftwareSerial.cpp: In member function 'void SoftwareSerial::end()':
    R:\arduino-1.0.5-r2\libraries\SoftwareSerial\SoftwareSerial.cpp:417: error: 'PCMSK2' was not declared in this scope
    R:\arduino-1.0.5-r2\libraries\SoftwareSerial\SoftwareSerial.cpp:417: error: 'PCMSK0' was not declared in this scope
    R:\arduino-1.0.5-r2\libraries\SoftwareSerial\SoftwareSerial.cpp:417: error: 'PCMSK1' was not declared in this scope

    Please Helpme

  4. Vatur

    I have arduino servino when i am compiling code with arduino uno its compiled and generates .hex file iam burning into Atmega8 but not working

    1. Stan Post author

      Hi Vatur,

      Did you check the link to the Arduino forum thread I posted above? Apparently there compatibility issues with the Atmega8 boards and the SoftwareSerial library. Looks like the ATmega8 doesn’t have Pin Change Interrupt hardware support and SoftwareSerial uses that for receiving data. Try compiling and running one of the example sketches that come with the SoftwareSerial library, to confirm it yourself. You might need to switch to an ATmega328P based board, or use a different approach / library, if you need your RX / TX pins free while using Bluetooth.


    2. Eshan Juneja

      Hi Vatur,

      Could you give me the circuit diagram of your assembled bot please? I am having a hard time assembling my bot.


  5. Eshan Juneja

    Hi Stan,

    Please could you provide me a detailed circuit diagram so that I’m able to understand how exactly the connections are to be done? Or if you could send me a picture of your own assembled bot with all connections properly visible? It would be of great help since microcontrollers is not my strongest subject.

    Please respond asap! It will be really appreciated.

    Thank you! 🙂

    1. Stan Post author

      Hi Eshan, I do not have a clear picture, as there are far too many wires in little space. I would suggest to start by getting each component working individually and then putting them together. You can follow the links at the bottom of the post to see how the servos are set up and how to hook up the Bluetooth module.


  6. Eshan Juneja


    Could you at least tell me how the connections are to be made? As in, could you tell me which ports/pins of each component are to be connected where? I’m sorry I’m asking so many questions but I’m a total amateur at this. I really need basic, step wise guidance.


    1. Stan Post author

      Hi Eshan, I have listed the key connections in the post itself. I also put links to my posts with getting the basics BlueTooth connectivity working. Sorry, I did not make a detailed circuit diagram beyond that.


      1. Eshan Juneja

        Not an issue, Stan. Thank you so much for the prompt reply. I will get back to you if I face any troubles.

  7. rose

    can please help me for making program which will run the robot having msp430 processor.. im not getting the programming for Bluetooth..plz help me.

    1. Stan

      Hi Rose, unfortunately I have no experience with the TI msp430 processor.



    Im runnning a very similair app , the only problem is that when i press the app buttons it gives me a broken pipe error . if i manually send the same signals to the arduino then the circuit works . any help ?

  9. Pingback: Eng 2 Day 21 Wednesday Nov 19 2014 | CVHS Engineering II Milham

  10. Alen

    I have problems to understand the connections and pins. Can I use this code with Arduino Mega2560, and which pins I should use. I think I understand it right when you use the SoftwareSerial, because the Uno does not have enough serial (Rx and Tx) pins like the Mega? Can i use the SoftwareSerial on Mega, or should I directly wire the BT modul to Rx and Tx pins?


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.