Loading...

Running Examples in Accessory Mode

The examples for the Mega ADK using the board in accessory mode require the following hardware and software:

  • a Nexus S, a Nexus One, a Samsung Galaxy Tab 10.1 or any other device supporting accessory mode (refer to the Getting Started page for more information)
  • Android SDK with all the updates up to the latest version of the APIs
  • Processing 2.0 or newer
  • Arduino 1.0 or newer
  • the USB Host library for Arduino
  • the Android Accessory library for Arduino
  • the Arduino ADK Tool for Processing
  • Eclipse + ADT plugin (optional and not explained here)

1. Android SDK

You can get the Android SDK from the Android Development website:

http://developer.android.com/sdk/installing.html

Unless you are planning on using Eclipse as part of your development, you can skip their step 3 of the installation.

Step 4 can be time consuming, you need to include the APIs for Google versions 10 and higher; consider installing everything at once.

2. Processing + Processing Libraries

Processing can be obtained from the following link:

http://processing.org/download/

Download the appropriate version (of Processing 2.0 or newer) for your OS and run the application. The first time Processing will ask you for the location you want to place your sketchbook. This is the way Processing defines your workspace and where it will be storing all your work by default.

We need to add a library and a tool to the standard installation. Download this file to your Processing sketchbook folder and uncompress it there.

You should now have two subfolders inside your sketchbook:

  • tools/Arduino_ADK: contains the compilation/uploading tool
  • libraries/ArduinoAdkUsb: contains the library to handle the USB communication
  • if you had an older version of the library and or tool (e.g. you downloaded it before 20120319), you should delete the old files and uncompress the new ones.

The next time you start Processing the tool and library will be ready to use.

On the upper right corner of your application you will see a small button stating the work mode for Processing. By default you will be working on normal mode. Click on it to change to Android mode. That should also change the color of your application from grey to green.

You can now use the editor to write code for your phone. In order to launch your ADK compatible code, you should look for the Arduino ADK option from the Tools menu.

3. Arduino 1.0 + Arduino Libraries

Download Arduino’s IDE from the following links. Note this is now the stable branch of Arduino, you might have this software already installed in your computer:

As with Processing, you need to run the IDE once to create your sketchbook folder. Once created, download this file. The two folders, “libraries” and “tools” need to be placed in your Arduino sketchbook folder.

If you are using the same location as a previous Arduino installation, be careful to not overwrite the existing libraries folder. Add the “/libraries/ArduinoAdkUsb” folder as you would a regular library.

As with the Processing bundle, if you had an older version of the library and or tool (e.g. you downloaded it before 20120319), you should delete the old files and uncompress the new ones.

Workflow

These tools require a particular process. You are writing code for two different pieces of hardware:

  • your phone/tablet, acting as USB client
  • your Mega ADK board, acting as USB host
  • since the Android device will be working in Accessory mode, the Arduino ADK board will be powering the device. Theoretically you should not worry about batteries as long as the Arduino ADK has power

A good way of working could be to:

  1. write you Arduino sketch first
  2. make sure you are getting the data you want by debugging the code using the serial monitor
  3. write a basic Android App that reads the data or sends commands to the Mega ADK
  4. design your Android Appl UI as needed

The libraries you installed both in Processing and Arduino come with Examples for you to try out the technology. You can browse them by going to the menu Files→Sketchbook→Libraries in both IDEs.

Known Issues

There are no known issues as for 20120319.