Lilypad bike jacket signal indicator

Before I started to work on Smart Turn signal indicator, I built another signal indicator jacket using a Lilypad Arduino and a Lilypad accelerometer. That was almost three years ago, but since then I have received quite a few inquiries about how it works. So I am going to give a quick overview about it in this post.

In case you didn’t come here after watching my youtube video, then here it is:

This jacket uses an accelerometer to detect the position of the hand, and activates the correct signal light. The accelerometer is attached to a glove, which is worn on the left hand. I used a Lilypad accelerometer because it can be sewn to the glove using conductive thread. Conductive thread is more flexible and lighter than wire. The Lilypad accelerometer outputs a voltage proportional to the acceleration on each of its three axes.  I used metal buttons to transfer the accelerometer signal from the glove to the jacket.

The schematic below shows all the components used to make this jacket. All connections are made using conductive thread. Notice how the LEDs do not have series resistors. This is because, unlike wire, conductive thread has a significant amount of resistance already. So there is no need to have additional resistors to limit current going though each LED.

Lilypad Bike Jacket schematic

Lilypad Bike Jacket schematic (click to enlarge)

And finally here’s a sample code for the Lilypad:

/*
 * This program implements a signal indicator jacket using a Lilypad Arduino and a 
 * Lilypad accelerometer. 
 * 
 * Author: Kasun Somaratne
 * Created: Dec 1, 2013
 * Modified: Dec 2, 2016
 */

void setup()
{
 // declare all digital pins as outputs
 for(int pin = 2; pin < 14; pin++)
 {
 pinMode(pin,OUTPUT);
 digitalWrite(pin,LOW);
 }
 // we will also need to use three of the analog pins as digital output pins
 for(int pin = A0; pin < A3; pin++)
 {
 pinMode(pin,OUTPUT);
 digitalWrite(pin,LOW);
 }
}

void loop()
{
 clearLights();
 // Analog pins A3 and A4 will be used to read the X and Y outputs of the Lilypad
 // accelerometer. Use the analog values to determine the correct signal to display. 
 if((analogRead(A4) > 500) && (analogRead(A3) < 450))
 {
 leftSignal();
 delay(100);
 }
 else if((analogRead(A4) < 450) && (analogRead(A3) > 500))
 {
 rightSignal();
 delay(100);
 }
 else if(analogRead(A3) > 600)
 {
 breakLights();
 }
 else
 {
 idleLights();
 }
}

void leftSignal()
{
 for(int pin = 6; pin > 1; pin--)
 {
 digitalWrite(pin,HIGH);
 delay(100);
 }
 
 for(int pin = 2; pin < 7; pin++)
 {
 digitalWrite(pin,LOW);
 } 
}

void rightSignal()
{
 for(int pin = 12; pin < 14; pin++)
 {
 digitalWrite(pin,HIGH);
 delay(100);
 }
 for(int pin = A0; pin < A3; pin++)
 {
 digitalWrite(pin,HIGH);
 delay(100);
 }
 for(int pin = 12; pin < 14; pin++)
 {
 digitalWrite(pin,LOW);
 }
 for(int pin = A0; pin < A3; pin++)
 {
 digitalWrite(pin,LOW);
 } 
}

void idleLights()
{
 for(int pin = 7; pin < 12; pin++)
 {
 digitalWrite(pin-1,LOW);
 digitalWrite(pin,HIGH);
 delay(100);
 }
 for(int pin = 11; pin > 7; pin--)
 {
 digitalWrite(pin,LOW);
 digitalWrite(pin-1,HIGH);
 delay(100);
 } 
}

void breakLights()
{
 for(int pin = 7; pin < 12; pin++)
 {
 digitalWrite(pin,HIGH);
 } 
}

void clearLights()
{
 for(int pin = 2; pin < 14; pin++)
 {
 digitalWrite(pin,LOW);
 }
 for(int pin = A0; pin < A3; pin++)
 {
 digitalWrite(pin,LOW);
 }
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s