Android + Arduino + USB Host + Pan Tilt LEDs
Combining analog and digital outputs with Android and Arduino. This tutorial will demonstrate the basics for using two servos to achieve basic basic pan and tilt functionality. In addition, digital control is demonstrated using two LEDs.
For additional background information on interfacing Android with the real world, check out my other introductory tutorials:
Hardware
Parts needed:
-
Android Device (1.6+)
-
2x Hobby servos
-
Pan / tilt bracket assembly
-
2x LEDs
-
2x 330 ohm resistors
-
Breadboard
-
Power supply
-
Hook-up wire
-
Android ADK Board*
-
– OR –
-
Arduino compatible and USB Host shield
*Supported boards include:
Google ADK board, Freeduino ADK board , Seeed Studio ADK board, and DIY Drones ADK board
Assembly
Connect the red, power lines of the servos to +5v, the black ground lines to GND, and the yellow signal lines to the desired output pins, 5 and 6 in the example (others can be used, but must be PWM capable). Also, connect the 330 ohm resistors in series with the anodes of the LEDs to the desired digital output pins, and the cathodes of the LEDs to ground. Here is a diagram of the completed circuit (created with Fritzing):
Software
Arduino Firmware
Next, upload the Arduino sketch to the microcontroller. The sketch uses the Microbridge implementation by Niels Brouwers. Microbridge uses Android Debug Bridge (ABD) forwarding over TCP, rather than the official Google Android ADK. You can checkout the source for the Arduino sketch from Github, or just copy and paste the following into the Arduino IDE.
Android App
Finally, install the Android Demo application onto the device. You can either download the pre-built .apkor checkout the source from Github:
git clone git://github.com/mitchtech/android_adb_pan_tilt_leds.git
Finally upload the app to the device (or browse to this page on the device and download the apk above). Connect the Android device to the USB Host board/shield, and start up the app.