Android + Arduino + USB Host + Dual Analog Input
Dual analog input with Android and Arduino. This article will demonstrate a basic dual analog USB input accessory.
For additional background information on interfacing Android with the real world, check out my other introductory tutorials:
Simple Digital Input
Simple Digital Output
Simple Analog Input
Simple Analog Output
Hardware
Parts needed:
- Android Device (1.6+)
- 2x Potentiometers
- 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 one terminal on each pot to ground and the opposite to +5v. Connect the wipers of each to an analog input pin, pins A0 and A1 in the example. 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 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
The next step is to install the Android Demo application onto the device. You can either download the pre-built .apk or checkout the source from Github:
git clone git://github.com/mitchtech/android_adb_dual_analog_input.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.









hello i try to compile some example of android code using adb but each one is filled with a lot of errors, can you help me i use adk 1.0 for arduino, arduino uno board and spark fun usb host shield,adb libraries for arduino
Hi Omar, have you installed the Microbridge library? If not, you will need to download the Adb library here and unpack it into the libraries directory of your Arduino installation as described in the Getting Started guide for Microbridge.
Hi,
I just find the same problem. The libraries seem to be well installed.
The “wiring.h” asked from ADB.h, usb.cpp and max3421e.cpp is missing; this is one group of errors.
But there’s “error: stray ‘\’ in program” and many others this king.
Any suggestion?
Copying and pasting the code directly from the website seemed to grab extra characters, so I have enclosed it within a github gist. It should now work correctly without stray ‘\’s now!
Hi michael great work, I cant get the application to run though on my samsung galaxys3 running android version 4.1.1.
It loads fine, but there is just a blank screen when the application comes up.
Nevermind, fixed it. There was a problem with the communication with the server.
Hi michael, thank you for posting this project. It same with my project at my college, but my project more difficult because the data from android must be able to transfer to another android. Have you been try to communicate between android and android ?