Arduino Bot Android Remote Control

140,171

602

85

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.


2 People Made This Project!

Recommendations

  • Make It Bridge

    Make It Bridge
  • Game Design: Student Design Challenge

    Game Design: Student Design Challenge
  • For the Home Contest

    For the Home Contest

85 Comments

0
azadur801
azadur801

6 years ago

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

0
cmelyo
cmelyo

6 years ago

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

I really would like to get it.

0
JibranE
JibranE

7 years ago

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

Errors.png
0
donmatito
donmatito

Reply 7 years ago

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

0
JibranE
JibranE

Reply 7 years ago

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

0
cmelyo
cmelyo

Reply 6 years ago

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?

0
dimitrakis1992
dimitrakis1992

Reply 7 years ago

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

0
RomanP6
RomanP6

7 years ago on Introduction

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!

0
donmatito
donmatito

Reply 7 years ago

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

0
braserito66
braserito66

9 years ago

donmatito thanks a lot. I did

0
ramcharan_v
ramcharan_v

Reply 7 years ago

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

0
ayoub cheggari
ayoub cheggari

7 years ago on Step 7

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

0
donmatito
donmatito

Reply 7 years ago on Step 7

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)

0
Harsh223
Harsh223

7 years ago on Introduction

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

0
donmatito
donmatito

Reply 8 years ago on Introduction

I suppose so - but I have not looked into it