Rapid prototyping for music, art and design work

Android Processing connecting to Arduino

There are two ways to connect Android to Arduino over USB. They are Android Debug Bridge Mode (ADB) and Accessory Mode (ADK). ADK supports only newer Android than 2.3.4 while ADB supports even older than 2.2. A demo in this page uses ADB.

Run first Processing application on Android

Install Android SDK

  • Download Android SDK. It is recommended to save it to Documents folder.
  • Open “android” file under “tools” folder. It lauches Terminal and Android SDK Manager.
  • Underneath “Tools”, check the box for “Android SDK Platform-tools”.
  • Select Android 2.2 (API 8) and install. This takes some minutes.
  • For Windows, you need also install the Google USB Driver Package under “Extras”.
Setup on Android device
  • Turn “USB Debugging” on your Android device. Settings application > Applications > Development
  • Connect the Android device to your PC using a USB cable. You don’t need to turn on USB storage.

Install Processing 2.0

  • Download  the latest 2.0 alpha release of Processing from the following URL.
  • Open of the Processing application
  • Switch from Standard mode to Android mode by clicking on the upper right corner.
  • Processing ask you to locate the Android-sdk-macosx folder.
  • UI theme should change from blue to green.
  • Type the following example Processing code
void setup () {
void draw () {
   line(0,0, 100, 200);
  • Run on device. Go to Sketch > Run on device
  • The device shows the Processing application that shows a line from the top left corner on a white background.
Install ADB library to Arduino IDE software
  • Download a ADB library from Microbridge project
  • If you have the latest Arduino IDE software, you need to modify a few constants in the library.
  • Replace Wiring.h manually with Arduino.h in Adb.h, max3421e.cpp, and usb.cpp as follows:#include “Wiring.h” -> #include “Arduino.h”
Hostshield variants
  • If you have old Hostshield from Sparkfun, you need to modify a couple of constants in the library. Product page – DEV-09628
  • Open max3421e.h in the library folder
  • Change two a couple of constants as follows:

#define PIN_MAX_GPX 8 -> #define PIN_MAX_GPX 7
#define PIN_MAX_RESET 7 -> #define PIN_MAX_RESET 8

Install ADB library to Arduino

  • Go to Arduino application in your PC. You don’t need to open the application.
  • Open a context menu by right click and select Show Package Contents
  • Go to Resources > Java > libraries
  • Copy the whole downloaded folder to the libraries folder
  • Restart Arduino

Assemble electronic to Arduino

  • Assemble ambient light sensor and LED. Schematic plan is here.
  • Please remember Sparkfun USB Host shield takes digital pin from D7 to D13 on the standard Arduino board. You can connect sensors and actuators only from all analog pins (A0 to A5) and digital pins from 2 to 6.
  • Make sure the dip switch on the USB hostshield is on. It is by the USB plug.
Permission on Android Processing

Arduino code has an excellent tutorial on the ADB library.

More info about the Android Debug Bridge implementation for Arduino can be found in the following page.


Facebook Twitter Email

Category: Course materials


4 Responses

  1. shailly panchal says:

    I successfully executed this whole tutorial but in the processing part,the sketch given just makes a line n tells the coordinates whereever the screen is touched..It is by no way connected to the Board.How can we transfer data from and to between the board and device? Plz reply.. :O Its urgent 🙁

  2. Bruno says:

    Hi, someone did this with Arduino Due?
    Because the Arduino Due doesn’t use the max3421e chip.]

Social links powered by Ecreative Internet Marketing