Using Android as robot remote control

September 4, 2010 at 5:18 pm 14 comments

The flea market car / robot saga continues… Controlling the robot from my laptop via Bluetooth was cool
, but running after the robot with the laptop in my hands kind of diminished the James Bond – feeling of it. Therefore, I decided that my first application I would create for my brand new Android smartphone would be a remote control for the robot!

Luckily, the online developer information (available at, provides a wealth of information for getting started. What was more, I actually found a sample application there, called BluetoothChat, that almost did exactly what I wanted to do. The BluetoothChat application makes a connection to a Bluetooth device (this will be the robot) and it allows to send text to it once connected (the text will be the robot commands).

Google provides a complete development environment for developing Android applications, which can be downloaded at Just follow the instructions over there to install the platform and create a “hello world” application. Connecting your phone over USB to the development computer allows you to debug / run the application on the phone. On my Ubuntu laptop, I have to restart the adb server as root after connecting the phone via USB:

(while in folder /android-sdk-linux_86/tools)
./adb kill-server
sudo ./adb start-server
./adb devices

Now let’s skip to the application. I wanted to change a few things to the BluetoothChat application:

  • actually get it connected to a Bluetooth device, because this wasn’t working right away.. 😦
  • after connecting to the robot over Bluetooth, I wanted to automatically start my PING – PONG handshake (Android says “PING” and the robot answers with “PONG”, which indicates the connection is established successfully and the robot should start listening for commands)
  • Instead of typing the commands in the text field I wanted some big buttons (forward, backward, left, right, …)

Connecting the BluetoothChat example to a Bluetooth device

I first tried connecting the BluetoothChat Android application to Bluetooth on my laptop, but it didn’t work. Whatever I tried, I always got a “service discovery failed” exception on the following line of code in

tmp = device.createRfcommSocketToServiceRecord(MY_UUID);

After a long time trying to solve this, I found this site, which suggested to change the line of code to this code:

Method m = device.getClass().getMethod("createRfcommSocket", new Class[] {int.class});
tmp = (BluetoothSocket) m.invoke(device, 1);

And this worked! Also, note that you have to connect at 57600 baud to the Android Bluetooth.

Do a handshake once connected

Once connected to the BlueSMIRF on the robot, the following should happen:

  • Android sends “PING\n” to robot
  • Robot receives this and sends “PONG\r\n” to Android
  • Android receives this, and knows the connection is succesfully established.
  • Now Android can send commands like “D,70,1” to set the servo to 70° and the drive motor to forward motion.

I changed the run() method of the ConnectedThread to do the handshake once connected: see code.

Big buttons that send commands to the robot

And now for the fun part.. I wanted to change the layout to have nine big buttons which would send the robot in a certain direction:

I used the example at this site to create the big button layout. Once a button is pressed, it will send a command over Bluetooth to the robot which will make it ride in that direction:

        mBRButton = (Button) findViewById(;

        mBRButton.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {

                // Send a message using content of the edit text widget

                String message = "D," + right + "," + backward + "\r\n";




And now a little movie to prove that it works!

The source code can be downloaded here.

edit: latest version of code is now available via


Entry filed under: Electronics, PIC18F. Tags: , , , , , .

Time for a new steering system Bluetooth communication between BlueSMIRF and Ubuntu

14 Comments Add your own

  • 1. mayank  |  September 16, 2010 at 7:45 am

    sir, thank you for uploading this amazing project, now i will try to make this robot for my final engineering project…….

  • 2. kim  |  September 27, 2010 at 12:51 pm

    hi sir,
    thanks for your information,
    I want make an application about robot remote controller.

    You made a remote control application on Linux,

    but I will make it on Window XP.

    Your source doesn’t work on my computer.

    I don’t know what is problem.

    and I use android phone. So I want to use Your application
    on my phone. Can you send a APK file?

    plz reply my comment or send mail. THANK you.

  • 3. Michaël Van den Steen  |  October 10, 2010 at 3:55 pm

    Cool man 😀 impressed!

  • 4. Rosu  |  October 30, 2010 at 4:59 pm

    What did you use to write the code on the android phone? Eclipse?

    • 5. Karel  |  November 2, 2010 at 8:26 pm

      Indeed I used Eclipse with the ADT plugin

  • 6. Anders Prier  |  October 31, 2010 at 5:12 pm

    Really cool project! 😀 atm im doing my own version of your project. So far I have compiled the program, and runned it on my HTC Desire, and finally got it connected it to my BlueSmirf modem and my PIC18F2553. Now there is just the fun part left.. Motor control etc. Instead of the button layout i have considered writing a “moving finger” control, still working on it, could be nice.

    Thanks, for the inspiration 😀

    • 7. Karel  |  November 2, 2010 at 8:29 pm

      Cool! Good luck with the project and keep me posted about it!

  • 8. voxiox  |  April 13, 2011 at 11:37 am

    how about with wif?i….controlling robot by android wifi ..its works or ..?
    thank you
    this is great article

  • 10. sarathiash  |  January 22, 2012 at 6:14 pm

    hello can you say which controller u have used for making that robot?

  • 12. gani  |  January 26, 2012 at 9:39 am

    pls send me apk file and details of project..

  • 13. wadson  |  May 28, 2012 at 8:31 am

    it is a foolish project

  • […] Using Android as Robot Remote Control Tutorial about controlling a robot using Android device and Bluetooth technology. […]


Leave a Reply to Karel Cancel reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Articles to be written…

Twitter – kr3l


RSS Google Reader Shared Stuff

  • An error has occurred; the feed is probably down. Try again later.

RSS Listening to..

  • An error has occurred; the feed is probably down. Try again later.

%d bloggers like this: