Albert’s Amarino-Powered Kung-Fu Jacket

by mrching

How do you talk to a jacket?  There was a time when if you did, people would look at you a little bit funny.

These days, with a little thing called an Android phone, a powerful little circuitboard called Lilypad Arduino, and an amazing toolkit called Amarino developed by Bonifaz Kaufmann, you can talk to your jacket — and even better, you can talk to someone else’s!

User Testing the Kung-Fu Jacket

The Amarino-Powered Kung-Fu Jacket that I developed started with an understanding of how an Android phone could talk to an Arduino board.  The connection is based on two necessary but ubiquitous components — a bluetooth modem for the Arduino and the free and open toolkit called Amarino that Kaufmann developed back in 2009.

Lilypad Arduino and Bluetooth modem

Amarino on the Android

The first test was to see if these items could talk to each other.  After some initial testing, success.

From there, I wanted to incorporate this technology into existing garments — not just because my sewing skills are quite rough but as much because I wanted to find a way to augment any garment that I had with smart technology.  The challenge was to design it in a way that allowed the garment to be resilient to washing.  The solution was simple in retrospect — soldered-on snaps! The snaps made it easy to remove the Lilypad board, the bluetooth and the battery when either the technology or the garment needed maintenance.

Snaps soldered onto a Lilypad board The next

Next, it was important to know where to put the output device — in this case, the vibrator to have maximum effect for the user.  After a bit of user-
testing including changing the conductive threat to a thicker one that provided more current and thus a stronger and more tangible vibration, I determined that the most sensitive part of my upper-quadrant (where the Arduino board was located) was the small area smack between my shoulders.  Since I wanted the vibrator to be felt by the user, I ended up sewing a place for snaps there.  (A few users have told me that the vibrator is so strong that if it was a bit stronger, it would give them a good shoulder massage).

Vibrator

With the platform in place, my final step was to program the Arduino board to sync with the multiple sensors on the Android phone in a unique way.  I started with the amazing accelerometer on an Android, a sensor that sends different data based on the orientation of the phone through 3 axes – x, y and z.  While it took a little learning to utilize that data for something that could then be translated into an output on the jacket, I got it to work in a basic and I think fun way!

Kung-Fu-ing with My Jacket Take 1

Kung-Fu-ing with My Jacket Take 2

The interesting part of the coding was whether or not to precisely to map the accelerometer movements with the outputs of the jacket — in other words to make it clear what orientations of the phone – up, down, horizontal – would respond to what outputs e.g. LED lighting up or a vibrator vibrating.  The looser the constraints e.g. LED lights up when phone is middle down to middle up made it more fun for the user to exaggerate their motions and to discover what actions was triggering what event.

You can see the code I used in the end below:

/*
Turns on vibrator when phone is vertical down and the LED when phone is horizontal.
Both turn off when the phone is vertical up.
Author: Albert Ching – May 2011
*/
#include <MeetAndroid.h>
// declare MeetAndroid so that you can call functions with it
MeetAndroid meetAndroid;
// starting with 1 LED
int vibrator = 16;
int LED = 11;
void setup()
{
// use the baud rate your bluetooth module is configured to
// not all baud rates are working well, i.e. ATMEGA168 works best with 57600
Serial.begin(57600);
// register callback functions, which will be called when an associated event occurs.
meetAndroid.registerFunction(vibrateoff, ‘A’);
pinMode(vibrator, OUTPUT);
pinMode(LED, OUTPUT);
digitalWrite(vibrator, LOW);
digitalWrite(LED, LOW);
}
void loop()
{
meetAndroid.receive(); // you need to keep this in your loop() to receive events
}
void vibrateoff(byte flag, byte numOfValues)
{
int values[]={0,0,0};
meetAndroid.getIntValues(values);
// xxx
int X=values[1];
int Y=values[2];
int Z=values[3];
if (Y < -4) {
digitalWrite(vibrator, LOW);
digitalWrite(LED, LOW);
}
else if (Y < 4) {
digitalWrite(vibrator, HIGH);
}
else if (Y > 4) {
digitalWrite(LED, HIGH);
}
else
{
digitalWrite(vibrator, LOW);
digitalWrite(LED, LOW);
}
}

Since the phone also had a number of other sensors, I also tested out using the receive SMS sensor in Amarino.  It was simple to set-up and
my intention was to have the LED change based on the message that was received from a user.  Unfortunately, I couldn’t get the coding correctly so I only got a single LED event but imagine that it would not be too difficult to figure out how to adjust the code below to figure this out.

/*

Turns on LED when phone receives an SMS.

Author: Albert Ching – May 2011

*/

#include <MeetAndroid.h>

// declare MeetAndroid so that you can call functions with it

MeetAndroid meetAndroid;

// starting with 1 LED

int LED = 11;

void setup()

{

// use the baud rate your bluetooth module is configured to

// not all baud rates are working well, i.e. ATMEGA168 works best with 57600

Serial.begin(57600);

// register callback functions, which will be called when an associated event occurs.

meetAndroid.registerFunction(LEDon, ‘A’);

pinMode(LED, OUTPUT);

digitalWrite(LED, LOW);

}

void loop()

{

meetAndroid.receive(); // you need to keep this in your loop() to receive events

}

void LEDon (byte flag, byte numOfValues)

{

int values[]={0};

meetAndroid.getIntValues(values);

// xxx

int X=values[1];

if (X = ‘hey’) {

digitalWrite(LED, HIGH); // set the LED on

delay(1000);              // wait for a second

digitalWrite(LED, LOW);    // set the LED off

} else if (X = ‘aloha’) {

digitalWrite(LED, HIGH); // set the LED on

delay(1000);              // wait for a second

digitalWrite(LED, LOW);    // set the LED off

delay(1000);              // wait for a second

digitalWrite(LED, HIGH); // set the LED on

delay(1000);              // wait for a second

digitalWrite(LED, LOW);    // set the LED off

delay(1000);              // wait for a second

digitalWrite(LED, HIGH); // set the LED on

delay(1000);              // wait for a second

digitalWrite(LED, LOW);    // set the LED off

delay(1000);              // wait for a second

digitalWrite(LED, HIGH); // set the LED on

} else if (X = ‘aloha baby’) {

digitalWrite(LED, HIGH); // set the LED on

delay(200);              // wait for a second

digitalWrite(LED, LOW);    // set the LED off

delay(200);              // wait for a second

digitalWrite(LED, HIGH); // set the LED on

delay(200);              // wait for a second

digitalWrite(LED, LOW);    // set the LED off

delay(200);              // wait for a second

digitalWrite(LED, HIGH); // set the LED on

delay(200);              // wait for a second

digitalWrite(LED, LOW);    // set the LED off

delay(200);              // wait for a second

digitalWrite(LED, HIGH); // set the LED on

delay(200);              // wait for a second

digitalWrite(LED, LOW);    // set the LED off

} else

{

digitalWrite(LED, LOW);

}

}

The great thing with this project (for me at least) is that my jacket is now a platform for expressing anything that my Android phone can do.  With the significant range of the Bluetooth (100 meters), it can even be controlled by someone far away.  After showing the jacket to many of my classmates, I’ve heard of use cases from a long-distance massage, a way to find someone subtly in a crowd, to give real-time feedback to a presenter or a teacher, to receive text message notifications without being close to our sometimes too clingy  mobile phones.

I can’t wait to continue the experimentation and am extremely grateful to Leah and the other members of the High-Low Tech lab for introducing this whole new world to me — and to Bonifaz for creating this very easy to use toolkit.  Mahalo nui loa!