Introduction: Arduino Bot Android Remote Control

Hello there,

In this instructable I would like to explore the connection between Arduino and Android. Both are open, easy-to-program environment (well, Android not so easy, but quite), and the interaction between them allows interesting human-to-device interaction.

The goal here is to drive a small Arduino bot of the simplest kind with an Android app, through Bluetooth connection. The robot itself will have nothing extraordinary and is inspired by the many tutorials out there on the Interwebs. But I have not found tutorials on how to create an Android remote control - so here it is.

Level and assumption :
- the reader is assumed to know its way around Arduino and electronics, including soldering, although there will be very little of it. Arduino starter kit level is sufficient.
- more importantly, the reader is assumed to have a working knowledge of Android. If not - I can recommend to work through the official Android tutorials, among others available online.
 

Step 1: Bill of Material

Here is a bill of material, with price list from Robotshop Europe. I like Robotshop for their customer service but these products are standard and can be found in other places

- Arduino UNO or equivalent (23.92€)
- Arduino-compatible 1A Motor Shield (12.95€)
- 2x GM9 geared motors (2x 4.29€)
- 2x GMPV wheels (2x 2.79€)
- (optional) 2x mounting brackets (2x 1.38€)
- 1 ball caster(1.78€)
- a 6 AA battery holder with 2.1mm jack (4.82€)

Not on RobotShop
- Bluetooth module (5€) such as this one on Ebay
- 2mm MDF plate
- some wires
- some screws and nuts
- a breadboard if you don't want to solder
- 6 Alkaline AA batteries or 6 NiMh rechargeable batteries (they provide 7.5V instead of 9V, but this is still sufficient for the GM9 motors)

Step 2: Mounting the Electronics

1) Mount the shield onto the UNO board. I assume your shield comes with soldered header. If not, you can find a nice picture on how to do it on this other instructable.

2) Mount the Bluetooth tranceiver on a breadboard.

3) Connect with wires the +5V and Ground from the Arduino board (actually, from the shield) to the +5V and Ground pins of the BT module

4) Connect with wires the Tx and Rx pins of the Arduino (ie, pins 0 and 1) to the Tx and Rx of the Bluetooth module

Warning 1 : some Bluetooth tutorials mention that you cross the connection (ie Tx to Rx and Rx to Tx). The way my module works, it needs to be parallel, ie Tx to Tx and Rx to Rx. You can try one way, and swap the connections if it doesn't work

Warning 2 : remember to unplug the BT module while loading the script on the Arduino. The Tx and Rx plug are actually the same as the Serial port used to communicate with your computer through USB, and the BT module will mess up the communication

Step 3: Prepare the Motors

1) Solder wires on each motor electrodes. If one motor turns much slower than the other, it is likely due to poor soldering (or poor connection at the motor shield)

2) (Optional) Screw the motor holders to the motors

Step 4: Finish the Assembly

1) Cut a piece of MDF - approximately 20x20cm

2) Mount the Arduino + shield on it as well as the battery pack on the MDF, as well as the ball caster on the back side. You can screw them or use double-sided tape - I used tape

3) Mount the motors on each side of the MDF. Here again you can use tape or screws, but I chose to screw them for better stability

4) Connect the motors wires to the motor shield

That's it ! As you can see, it's a really simple robot layout. You can plug the jack from the battery pack into the Arduino, to test that the Arduino is lighting up and the Bluetooth module is blinking

Step 5: The Software Part

The logic behind the software is the following

1) An Android app gives user the ability to connect to and disconnect from the bluetooth module. When connected, a serial link will exist between the smartphone and the Arduino robot

2)  The user can then use arrows to drive the robot and a "stop" button to, well, stop it. Every time the user presses a button, the app sends a character (eg "f" for forward, "s" for stop and so on)

3) The Arduino board listens to the Serial port. When a character is received, it drives the motors accordingly.

Step 6: The Arduino Sketch

Upload the attached code to the Arduino Uno. Remember, to unplug the bluetooth module while doing so.

As you can see 5 intructions are defined : move forward, backwards, left, right, and stop. All motions are executed at full speed (the GM9 motors are geared, and thus not turning very fast) but you could change the speed value if you want.

A nice addition would be a capability to select the speed directly from the Android app, or even adjust the speed to each wheel to correct for small differences that always exist between geared motors. If you implement it, please let me know and I'll add the code to the Instructable !

Step 7: The Android App

Extract the following file to your usual Android project folder - such as the Eclipse workspace if you use Eclipse.

Then, connect your Android smartphone to your computer and launch the app - it will be automatically transfered to your smartphone.

Quick run-through. The app has two main Classes :

1) AndroidRemoteActivity, the main activity, that take the layout activity_android_remote and inflates it. It also associates actions with buttons, such as sending the character associated with each arrow.

2) a BtInterface class that provides all the utility tools to manage the Bluetooth connection, such as connecting, disconnecting, and listening and sending messages over the Serial port. This utility comes from this tutorial (FR)

Warning 1 : the Bluetooth module name is hard-coded in the app. Mine is "HC-05". If your module is different, you should change that name.
Warning 2 : The Bluetooth module should be paired with your phone prior to attempting connection. To do so, power the Arduino with the BT connected, turn on the Bluetooth on your smartphone. Search for your module, click on it (if a password is asked, it is usually "1234" or "0000") - et voilà, it's paired.

The most important actions are performed when

- The user clicks on "Connection" - do it when the Arduino board is powered, with the Bluetooth module blinking. It should stop blinking when you see the "Connected" message in the app

- The user clicks on an arrow or on "stop". The app send a character to the Arduino through the Serial connection. You should see the robot moving while at the same time as a confirmation message appears on the app.


Comments

author
DXGJyothish made it! (author)2017-03-18

Can we use bluej

author
azadur801 made it! (author)2016-11-01

PLZ HELP ME,,, HOW CAN I INSTALL THIS APPS

author
cmelyo made it! (author)2016-06-12

Hi, At the end did anyone move the project to Android Studio / Gradle?

I really would like to get it.

author
JibranE made it! (author)2015-12-07

I m getting these errors.. Can u plz help me out???

Errors.png
author
donmatito made it! (author)donmatito2015-12-08

Hello,

Sorry, this is an old project, coded in Eclipse. Now, Android uses Android Studio and Gradle, which are not compatible.

Here is a link that might help

http://developer.android.com/sdk/installing/migrate.html

author
JibranE made it! (author)JibranE2015-12-09

Thank u for ur assistance.. Link was helpfull..

author
cmelyo made it! (author)cmelyo2016-06-12

Hi, at the end , did you get the project moved to Android Studio?

I really would like the code with gradle. Anyone has it done?

author
dimitrakis1992 made it! (author)dimitrakis19922016-02-05

hello JibranE. Use this app instead of java and it will work just fine https://play.google.com/store/apps/details?id=braulio.calle.bluetoothRCcontroller

author
masahiro45weakro123 made it! (author)2016-02-04

can i have the whole code please! thank you

author
RomanP6 made it! (author)2015-08-27

Have anyone tried to import it to Android Studio? I'm trying and it gives me:
Error:FAILURE: Build failed with an exception.

* What went wrong:

Task '' not found in root project 'AndroidRemote'.

Could anyone help me with this problem? Thanks!

author
donmatito made it! (author)donmatito2015-12-08

Hello,

Sorry this is an old project, initially coded with Eclipse. Now Android uses Android Studio and Gradle, which are not compatible.

Here is a link that might be helpful

http://developer.android.com/sdk/installing/migrate.html

author
Mahesh Dodhani made it! (author)2015-10-07

pdf download ni hote bhooo

author
braserito66 made it! (author)2014-02-01

donmatito thanks a lot. I did

author
ramcharan_v made it! (author)ramcharan_v2015-09-01

sir we are making a robot that can be controlled by bluetooth so iam thinking to create a new app can u help me in this
hrlp me how to dhis apps

author
ayoub cheggari made it! (author)2015-08-04

please how to send the app to the smartphone???

author
donmatito made it! (author)donmatito2015-08-11

Simply connect your phone to your computer and run the app from the editor (once again this tutorial assumes you have basic knowledge of how to create a basic android app)

author
ayoub cheggari made it! (author)2015-08-04

thanks man !!!

author
Harsh223 made it! (author)2015-06-27

Can you tell me how to make a app like yours with MIT app inventor!! I am poor in it! and also tell me whats the difference between PILL and PWM

author
donmatito made it! (author)donmatito2014-07-20

I suppose so - but I have not looked into it

author
Harsh223 made it! (author)Harsh2232015-06-27

Yes you can dude! but robokits india sells products pretty costly 1 recomend www.roboindia.com or www.robocraze.com they are the best although i use major products of robokits india! like rhino board etc.

author
Harsh223 made it! (author)2015-06-27

Ordered all parts online but i ordered The motor shield for 2A[By df robots] any changes in the code??Please reply me!

author
donmatito made it! (author)donmatito2015-06-27

I don't think so, but you might want to use an external power source for your shield. You will be able to use more powerful motors by the way.

http://www.dfrobot.com/index.php?route=product/product&product_id=69

author
Harsh223 made it! (author)Harsh2232015-06-27

Thanks Dude! I will be getting all the parts within a week. Can you tell me how to make a bluetooth based voice controlled robot.(*_*)

author
HimanshuP2 made it! (author)2015-05-31

Android App:
BlueUino: Bluetooth Remote for Arduino, Control your Arduino Over Voice as well as Buttons
https://play.google.com/store/apps/details?id=g.patels.blueuino

If you want to make app like this as per you requirements please Email me : micky.patel41@gmail.com.
Visit web site for more info : blueuino.blogspot.com.

author
dimitrakis1992 made it! (author)2015-05-16

Hello i would like to ask you if i use only this app from google store https://play.google.com/store/apps/details?id=pl.mobilerobots.vacuumcleanerrobot it will work?

author
iceland.szt made it! (author)2015-03-22

Hy! I was wondering if instead of Arduino uno I can use Due? Are there any significant changes? Thanks in advance.

author
LokeshK2 made it! (author)2015-01-22

what r the applications of this project???????

author
moon_toon101 made it! (author)2015-01-04

nice work man keep it up...

temp_2032605900.jpg
author
kaQn4p made it! (author)2014-12-01

is it possible that you may post the arduino code? i would be very interested in it

author
donmatito made it! (author)donmatito2014-12-07

It is in step 6

Thank you for your interest

author
kaQn4p made it! (author)kaQn4p2014-12-07

Thank you very much !

author
waleedthesky made it! (author)2014-12-06

Hy, i want to use this app in my Final Year Project and not with Arduino but with Raspberry-Pi

please tell me will it work?

and can you please send me the code,

author
donmatito made it! (author)donmatito2014-12-07

Unfortunately, Instructables has a "be nice" comment policy, so I can't really answer fully your question. if it is your final year project, wouldn't it be more productive for you to write it yourself?

Regards

Matthieu

author
waleedthesky made it! (author)waleedthesky2014-12-07

i'm asking about the code of that app which you used in Android

author
marwan.shaheen made it! (author)2014-11-22

Thank you so much for the clear explination.

author
ankon.risalat.7 made it! (author)2014-11-16

;l;l

author
ankon.risalat.7 made it! (author)2014-11-16

;l;l

author
3DGeneral made it! (author)2014-08-22

I have an RN 42 Bluetooth module....will it work the same?

author
donmatito made it! (author)donmatito2014-08-23

I suppose because the general principle is the same, but you'll have to read the related documentation about the wiring I advise

author
ankushwork2 made it! (author)2014-01-16

I am a newbie to this electronics stuff, i heard a bit about beaglebone black. I want to ask how the connection is made between your smartphone and arduino, and how the arduino board is able to decode what key you are tapping on your smartphone.?

Please do reply.

author
donmatito made it! (author)donmatito2014-07-20

Hello, sorry I didn't notice your question. the connection between the smartphone and the arduino is made with Bluetooth. In the software, it is equivalent to a serial connection - like if there was a direct cable connecting the two devices.

Hope it helps !

author
brians6067 made it! (author)2014-07-01

what is the name of this app ?

author
donmatito made it! (author)donmatito2014-07-20

the app is not available on the appstore, if that is your question, because the goal here was to develop it and compile myslef

author
ehsanabdullah made it! (author)2014-05-15

very nice project ,,,i also made it

author
donmatito made it! (author)donmatito2014-07-20

excellent !

author
vjain8 made it! (author)2014-03-28

Can i use arduino motor shield rev3 if so what are the codes

author
donmatito made it! (author)donmatito2014-07-20

I suppose so - but I have not looked into it

author
shyeah1983 made it! (author)2014-02-21

I extracted the androidremote file to my workspace but it doesn't show up as a project on Eclipse.... Is there a step that I'm missing? When i create a new android app using Eclipse, the file shows up in my workspace and Eclipse regognizes it as a project.

author
donmatito made it! (author)donmatito2014-07-20

I think you have to "import" the project file in the Eclipse software. Let me know if you have found how to do it.