How to Control Arduino Robot using Android

I would like to explore the connection between Arduino and Android.
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 simple steps to do its.
Step 1: All Materials


  • Arduino UNO or equivalent
  • Arduino-compatible 1A Motor Shield
  • 2x GM9 geared motors
  • 2x GMPV wheels
  • (optional) 2x mounting brackets
  • 1 ball caster
  • a 6 AA battery holder with 2.1mm jack
  • 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  all electronics parts 


  • 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.
  • Mount the Bluetooth tranceiver on a breadboard.
  • 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
  • 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 :
  • 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.
  • 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

Solder wires on each motor electrodes. If one motor turns much slower than the other, it is likely due to poor soldering .
Step 4: Finish the assembly

  • Cut a piece of MDF - approximately 20x20cm
  • 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
  • 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
  • Connect the motors wires to the motor shield
  • That's it ! As you can see, it's a really simple robot layout.
Step 5 : Its Software time
  •  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
  • 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)
  • 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.
Download the source code of arduino_for_android_remote
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. 
 Step 7: The Android App
 For Next Step you need to read next Post :
Control Your Robot Using Android Apps
0 Comments
Disqus
Fb Comments
Comments :

0 comments:

Post a Comment