For halloween, each IDEO location held a one-hour pumpkin carving competition. I thought it would be interesting to see how much tech I could jam into a pumpkin within the time limit. Luckily, I had an old pneumatics kit under my desk and recently stumbled upon an incredibly simple way to get my iPhone to talk to Arduino. I was able to conceptualize, build, and program this wirelessly-controlled-pneumatic-eye-popping pumpkin in just over an hour, barely missing the deadline but experiencing how powerful these low fidelity prototyping tools could be.

Learn more after the jump…

There are a few ways to get an iPhone to talk to an Arduino, but none are as quick and simple as pairing up the mobile app TouchOSC (for Android and iOS) with Processing. The control system is practically plug and play and very minimal coding knowledge necessary to get up and running (so don’t be afraid if you’re new to the game).

This setup has been around for a few years but it hasn’t gained much traction for its potential value in low fidelity prototypes. The time investment is incredibly low compared to any other phone/Arduino strategies, serving as a great early filter for interaction concepts or realizing your wildest dreams of an iPhone controlled robo-pumpkin.

To make one thing clear: this prototyping method has a bit of  ‘smoke and mirrors’  in that the smartphone doesn’t directly communicate with the Arduino, but uses a computer as a receiver and translator between the two.  There are a few ways to take out the middleman but they take a bit more setup and a few more tools that would make the build lengthier.

TouchOSC is a great app for iPhone and Android that helps make this entire process incredibly easy on the interface side. The program allows you to build a basic interface via a desktop app  “TouchOSC Editor”. You can compile basic interaction objects (buttons, toggles, faders, etc…) onto an iPhone/iPod Touch/iPad screen which you can then easily transfer to any iOS device.

The custom TouchOSC interface creates “Open Sound Control” (OSC) signals sent via wifi that are received by an open Processing sketch on a computer. The Processing sketch then writes the signal to serial, which is transmitted wirelessly to the Arduino with a pair of Xbee Modules. The Arduino is hooked up to two air pistons powered by a bike pump and 2 liter bottle reservoir.

If any of these terms don’t make sense and/or you want to give it a shot yourself, there are a few great tutorials that go into more detail and make it easy to get started:

Sparkfun Tutorial for LED Control (doesn’t address Xbee)

MIT Robotics Class Tutorial with LED/Servo Control (with Xbee but with non-standard board)

 

***Note:  Neither the tutorials address an accessible Xbee setup. Here is what I used:

Arduino Uno,  Xbee Modules (x2)Xbee USB Dongle, and Xbee Arduino Shield

Check out Processing and Arduino Code I used in this project here

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
//-----------------------Start Arduino Code------------------------------
 
int message = 0; // This will hold one byte of the serial message
int eyesPin = 9; // What pin are the eyes connected to?
int eyes_val = LOW; // eyes_val will be HIGH or LOW
 
void setup()
{
Serial.begin(9600); //set serial to 9600 baud rate
}
 
void loop()
{
if (Serial.available() > 0)
{ // Check if there is a new message
message = Serial.read(); // Put the serial input into the message
 
if (message == 'R')
{ // If a capitol R is received...
eyes_val = HIGH; // Set eyes_val to HIGH and eyes are out
}
if (message == 'r')
{ // If a lowercase r is received...
eyes_val = LOW; // Set eyes_val to LOW and eyes are in
}
}
digitalWrite(eyesPin, eyes_val); // Write digital value to eyes
}
 
//----------------------------end Arduino code--------------------------------
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
//----------------------------------start processing code------------------------------------
 
import oscP5.*; // Load OSC P5 library
import netP5.*; // Load net P5 library
import processing.serial.*; // Load serial library
 
Serial arduinoPort; // Set arduinoPort as serial connection
OscP5 oscP5; // Set oscP5 as OSC connection
 
float eyes_val;
 
//--- Function: setup
void setup()
{
 
oscP5 = new OscP5(this,8000); // Start oscP5, listening for incoming messages at port 8000
arduinoPort = new Serial(this, Serial.list()[0], 9600); // Set arduinoPort to 9600 baud
}
 
//--- Function: oscEventThis runs whenever there is a new OSC message
void oscEvent(OscMessage theOscMessage) {
{
String addr = theOscMessage.addrPattern();
if(addr.equals("/1/push1")) {
eyes_val = theOscMessage.get(0).floatValue();
}
}
}
 
 
//--- Function: pneumatic eyes on/off
void draw()
{
println(eyes_val);
if (eyes_val > 0.5) {
arduinoPort.write('R');//sends signal for eyes out
delay(200);
}
else {
arduinoPort.write('r');//sends signal for eyes in
}
 
}
 
//----------------------------------end processing code------------------------------------

At IDEO we are excited about “sketching in hardware” (super-fast rough interactive prototyping).  Here are some other related IDEO Labs posts:

Sketching In Hardware

Game On! A Workshop At  IIT

Quick-n-Dirty Multi-Touch: Flash API + Wiimote

4 Comments:

  1. PMK

    06/12/2011 at 4:46 pm // Permalink

    Very cool, great idea for a pumpkin! Hopefully you were able to scare some trick-or-treaters.

  2. lukasz

    07/02/2012 at 6:39 am // Permalink

    this is amazing! I love me some processing. didn’t know you could run touchosc on phones though, very cool! hey there is something funky going on with your blog though:

    http://localhostr.com/files/QOrYJQa/Screen+Shot+2012-02-07+at+8.45.54+AM.jpg

    your paragraph tag is extending outside of your content div. it’s because of the github coded. you can fix this simply by amending a width to this css rule.

    .gist {
    color: black;
    width: 500px; // or whatever width you would like
    }

    its in your embed.css :)

Leave your comments