A+A (Android plus Arduino)

June 15, 2011
6:00 pmto8:00 pm

Mobile meets Physical

Tom Igoe and Shawn Van Every will go over using mobile devices to interface with and control hardware.

Class Notes:

The ADK

Google has created the Android Open Accessory Development Kit it allows USB accessories to interact with Android applications.

Note: The accessory is the USB host

Their official download is available here: https://dl-ssl.google.com/android/adk/adk_release_0512.zip

The kit’s hardware design is based on Arduino and includes arduino libraries that work with the hardware reference

It also includes an Eclipse project for an Android application: DemoKit

Processing for Android Setup

Processing a creative coding environment has support for Android. Since Processing is much easier to get started with than Eclipse/Android SDK, we thought it would be the tool to demo this with and the Arduino folks are building some nice stuff ;-)

Download Processing: http://processing.org/

Download the Android SDK: http://developer.android.com/sdk/index.html

About Processing for Android: http://wiki.processing.org/w/Android

Note: We’ll need the Android API revision 10.

In order to work with the Arduino, we’ll need two other items which are on the thumb drive we are passing around.

1: Specifically in the “Processing/tools” directory we’ll need the folder it contains to be placed into Processing’s sketchbook, “tools” folder.

2: We’ll also need, from the Processing/libraries directory the entire ArduinoAdkUsb folder should be copied into the user’s Processing sketch folder in a folder called “libraries”

Arduino Setup

Version 1 beta is required:
http://files.arduino.cc/downloads/arduino-1.0-beta1.dmg OSX
http://files.arduino.cc/downloads/arduino-1.0-beta1.zip Win
http://files.arduino.cc/downloads/arduino-1.0-beta1.tgz linux 32 bit
http://files.arduino.cc/downloads/arduino-1.0-beta1-64.tgz linux 64 bit

Install the two libraries from the thumb drive’s “Arduino” directory into the Arduino “libraries” folder which should be in your Arduino sketchbook folder.

Processing for Android Hello World


PFont myFont;
char theKey = '0';

void setup() {
// No size, use full screen
// height, width variables are available

// Force specific orientation
//orientation(PORTRAIT);
orientation(LANDSCAPE);

String thisFont = PFont.list()[0];
myFont = createFont(thisFont, 128);
textFont(myFont, 128);
}

void draw() {
background(255);
fill(#2389F6);
text(theKey, width/2, height/2);

}

void keyPressed() {
theKey = key;
}

More advanced, with Permissions


import android.content.Context;
import android.os.Vibrator;

PFont myFont;
char theKey = '0';
Vibrator vibrator;
long[] pattern = {200,800,200,800};

void setup() {
// No size, use full screen
// height, width variables are available

// Force specific orientation
//orientation(PORTRAIT);
orientation(LANDSCAPE);

String thisFont = PFont.list()[0];
myFont = createFont(thisFont, 128);
textFont(myFont, 128);

vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

}

void draw() {
background(255);
fill(#2389F6);
text(theKey, width/2, height/2);

}

void keyPressed() {
theKey = key;
vibrator.vibrate(pattern, 1);

}

It requires the “VIBRATE” permission. You can add that via the Processing, “Android” menu and choosing the “Sketch Permissions” item.

Now to start with Arduino

23 comments to A+A (Android plus Arduino)

You must be logged in to post a comment.