Você está na página 1de 8

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.

Related
About This Instructable
License:
5,933 views
48 favorites
donmatito
Follow Follow 19
More by donmatito
arduino arduino android android robot robot remote remote
control control
Tags:
myRobot - DIY Robot
by aneophyte
2-Wheel Self Balancing
Robot by using Arduino
and MPU6050
by Ufactory
DIY RC Robot with your
Android Phone Tutorial
Part 1: from Android
phone to the microco
Control a NXT Robot with
Android and HTML5
Arduino bot Android remote control by donmatito
+ Collection + Collection Download Download 7 Steps 7 Steps Favorite Favorite
let's make
share what you share what you
make > make >
Explore Create Contests Community Login
Arduino bot Android remote control 1/7/2014
http://www.instructables.com/id/Arduino-bot-Android-remote-control/?ALLSTEPS 1 / 8
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
See More See More
by wbeer
DIY RC Robot with Your
Android Phone Tutorial
Part 2:
Bluetooth/Microcontroller
Arduino bot Android remote control 1/7/2014
http://www.instructables.com/id/Arduino-bot-Android-remote-control/?ALLSTEPS 2 / 8
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
Arduino bot Android remote control 1/7/2014
http://www.instructables.com/id/Arduino-bot-Android-remote-control/?ALLSTEPS 3 / 8
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
Arduino bot Android remote control 1/7/2014
http://www.instructables.com/id/Arduino-bot-Android-remote-control/?ALLSTEPS 4 / 8
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
Arduino bot Android remote control 1/7/2014
http://www.instructables.com/id/Arduino-bot-Android-remote-control/?ALLSTEPS 5 / 8
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 !
arduino_for_android_remote.zip 934 bytes
Step 7: The Android App
Arduino bot Android remote control 1/7/2014
http://www.instructables.com/id/Arduino-bot-Android-remote-control/?ALLSTEPS 6 / 8
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.
AndroidRemote.zip 1 MB
Arduino bot Android remote control 1/7/2014
http://www.instructables.com/id/Arduino-bot-Android-remote-control/?ALLSTEPS 7 / 8
Post Comment Post Comment
yesterday
Reply Reply 4DIY CHANNEL says:
awesome! very useful.
About Us
Who We Are
Advertise
Contact
Jobs
Help
Find Us
Facebook
Youtube
Twitter
Pinterest
Google+
Resources
For Teachers
Artists in Residence
Gift Pro Account
Forums
Answers
Mobile
Download our new apps for
iOS and android!
Android Android iOS iOS
Go Pro Today Go Pro Today
We're Hiring! We're Hiring!
Join our Join our
newsletter: newsletter:
Terms of service Terms of service || Privacy Policy Privacy Policy || Legal Notices & Trademarks Legal Notices & Trademarks || Mobile Site Mobile Site
Join! Join!
Copyright 2013 Autodesk Inc. All rights reserved.
English English enter email
Arduino bot Android remote control 1/7/2014
http://www.instructables.com/id/Arduino-bot-Android-remote-control/?ALLSTEPS 8 / 8

Você também pode gostar