Accelerometer powered LED dress

Let’s be honest for a moment, doesn’t everyone want a dress that lights up at your very whim? No? Alright, well I do. It’s pretty straightforward, though the programming gets a wee bit tricky. So pick up your pencil, sketch out a design and then we’ll talk parts.Here

Accelerometer powered LED dress

Step 1: Material

Major Components in Project

Lilypad Simple Snap and Snap Protoboard.  – available on https://www.sparkfun.com/products/10941 for $29.95 and https://www.sparkfun.com/products/10940 – $9.95
Lilypad FTDI board and cable – https://www.sparkfun.com/products/10275 $14.95
LilyPad micro LED’s – shttps://www.sparkfun.com/products/10753 at $3.95 for 5. I used 30 of them. (you can also use the regular sized LED’s but I chose to use the micros.)
LilyPad Accelerometer – https://www.sparkfun.com/products/9267 $24.95
Insulated wire – I used a ribbon cable from Sparkfun, but you can also just purchase it at a local hardware store.
Soldering Iron
Alligator clips and Heat Shrink Tubing
Dress or project on which you want to put your magical lights – I used a skirt I already made several months ago.

Step 2: Schematics

Schematics

Before jumping right into this project, be sure to draw a basic sketch of what you want your project to look like. Make sure you add in circuits and where everything is going to go.

Step 3: Soldering lights

Depending on the type of fabric you have, you may be able to use electrically conductive thread (available on SparkFun). I however, did not get that chance as I used an acetate taffeta fabric and actually ended up burning  a hole in my skirt due to a short in my circuit. I therefore, decided to solder  my lights to insulated wire to avoid further burnings.

Cut up a section of the ribbon cable, and split each wire and strip the ends. These are what we will solder to the lights and the accelerometer. I used colored wires as positive and grey as negative.

Make sure you know how to work a soldering iron, or ask someone to help you, as the lights are really small and it’s easy to burn a hole all the way through the light board

Once you’ve soldered the lights, check to make sure the solder worked. Use alligator clips and simply connect them to the positive and negative pins of the LilyPad.

Also, at this point, solder the larger section of the ribbon cable to the Lilypad Snap board. Each pin gets its own wire, make sure to solder a wire to the positive and negative pins as well, we will use them in a bit.

Step 4: Adding Lights to the Dress

Once again, because I used an acetate fabric, I simply had to burn small holes in the fabric for the LED wires to poke through to the underside. I also burned a slightly larger hole to allow the larger ribbon cable and the negative leads to reach the LilyPad board.

After you’ve got all of the LED’s situated onto your project, connect them back up to the larger ribbon cable. Be sure to solder them together and then cover it up with a bit of heat shrink tubing.

By this point you should have all of the lights and the Accelerometer connected to the LilyPad. I hid mine in a drape on my skirt, but you can put your LilyPad board anywhere you like.

Step 5: Programming

Now here’s the tricky part. In order to really get accurate accelerometer readings you need to either wear the skirt or use your project in the way it’s intended to be used. Otherwise you get absolutely useless readings.  I used Arduino as the programming platform. So put on the skirt, hook it up to the computer, and prance around your basement carrying your laptop for a minute or two.

In order to get readings you need to have uploaded code to the Lilypad and then turned on the serial monitor (the magnifying glass in the upper right corner).

Here is the code I used. It averages the accelerometer readings to make it more stable.

//***Code adapted from Programming Interactivity (pp. 234-235) by Joshua Noble***

int led1 = 5;
int led2 = 6;
int led3 = 9;
int led4 = 10;
int led5 = 11;

int xpin = A3;         // x-axis of the accelerometer
int ypin = A4;         // y-axis
int zpin = A5;         // z-axis (only on 3-axis models)

int xVal = 0;
int yVal = 0;
int zVal = 0;

int xVals[8]; //an array of the last 8 x coordinate readings
int yVals[8]; //an array of the last 8 y coordinate readings
int zVals[8]; //an array of the last 8 z coordinate readings
int xAvg = 0; //the x value we’ll read eventually
int yAvg = 0;
int zAvg = 0;

int currentSample = 0;

void setup()
{
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(xpin, INPUT);
pinMode(ypin, INPUT);
pinMode(zpin, INPUT);
Serial.begin(9600);
}

void loop()
{
///we use currentSample as an index into the array and increment at the
//end of the main loop)(), so see if we need to reset it at the
//very start of the loop

if (currentSample == 8) {
currentSample = 0;
}
xVal = analogRead(xpin);
yVal = analogRead(ypin);
zVal = analogRead(zpin);
//This stores 8 values. Basically, it stores
//the last 8 values read and averages it continually (later in the code).
xVals[currentSample] = xVal;
yVals[currentSample] = yVal;
zVals[currentSample] = zVal;

//here is where the values are added so that you
//eventually get the last 8 values

for (int i=0; i < 8; i++) {
xAvg += xVals[i];
yAvg += yVals[i];
zAvg += zVals[i];
}
//These will read the first 7 cycles, but that won’t make a huge difference
//unless you need to read the value from the accelerometer right away

//Calculate the average
xAvg = (xAvg / 20);
yAvg = (yAvg / 20);
zAvg = (zAvg / 20);

//Print out the average
Serial.print(xAvg);
Serial.print(” “);
Serial.print(yAvg);
Serial.print(” “);
Serial.println(zAvg);
delay(100);

currentSample++; //increment the sample

if (xAvg > 570 && xAvg < 590)
{
digitalWrite(led1, HIGH);
delay(100);
digitalWrite(led1, LOW);
delay(100);
digitalWrite(led2, HIGH);
delay(100);
digitalWrite(led2, LOW);
delay(100);
digitalWrite(led3, HIGH);
delay(100);
digitalWrite(led3, LOW);
}

}

 

For more detail: Accelerometer powered LED dress


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top