Pre Lab 3.3: Configuring development environment for ADK

In the next Lab, we’ll learn to use ADK Main Board which enables Android phones to interact with and control physical world. However, we need to properly configure Arduino and Android development platforms before we can start using ADK boards with Android.

Arduino Configuration

We need to include additional libraries to provide the logic for the ADK board to act as a USB Host to which Android phones can be connected. This allows the board to initiate transactions with USB devices (Android phone in our case). Follow this simple step to add the required libraries:

  1. Install the avr-libc library by executing sudo apt-get install avr-libc (although it might already be installed).
  2. Download this .zip file and extract the contents to <Arduino_Installation_Directory> => libraries folder.
  3. Verify that you now have two new directories in the Arduino libraries/ directory: AndroidAccessory and USB_Host_Shield:

 

Configuring Android IDE

  1. Start Android SDK Manager
  2. scroll to Android 5.0.1 (API 21) => Google APIs and enable the check box beside it as shown in the figure.
  3. Click on install packages button to install Google APIs packages.

 

What is Accessory Development Kit (ADK)?

The Android 3.1 platform introduced Android Open Accessory support, which allows external USB hardware to interact with an Android-powered device in a special “accessory” mode. When an Android-powered powered device is in accessory mode, the connected accessory acts as the USB host (powers the bus and enumerates devices) and the Android-powered device acts as the device.

When you set up an ADK hardware project you are building a so-called Android accessory. Your hardware project is an accessory for the Android device such as, for example, a keyboard would be for a PC, with the difference being that your accessory provides the power for the whole system. Accessories need to support the already mentioned power supply for the device and they must adhere to the Android accessory protocol. You can learn more about the ADK and the Open Accessory Standard have a look at the Android developer pages here.

With an Android phone and the Arduino ADK Board , you can use whatever sensors and actuators you require to create your own accessories and to make Android devices interact with the physical world.

ADK Components

The main hardware and software components of the ADK include:

  • A USB micro-controller board that is based on the Arduino Mega2560 and Circuits (now referred to as the ADK board). The ADK board provides input and output pins that you can implement through the use of attachments called “shields.” Please note that you have been provided with an Arduino shield.  An Arduino sketch installed on the board defines the board’s functionality and interaction with the attached shield and Android-powered device.
  • An ADK shield that affixes atop the ADK board implements the input and output points on the board. The shield makes it easier to connect sensors and other devices e.g. joystick, LED outputs, and temperature and light sensors.
  • A library located in the libraries/USB_Host_Shield provides the logic for the ADK board to act as a USB Host. This allows the board to initiate transactions with Android Phones.
  • The Android accessory protocol library, which is located in the libraries/AndroidAccessory directory. This library defines how to enumerate the bus, find a connected Android-powered device that supports accessory mode, and how to setup communication with the device.