Stephanie – LED Shirt

My final project was to sew a shirt that had RGB LEDs on the sleeves whose flashing modulation could be controlled by three buttons in the palms.

Since the final presentations on Wednesday I’ve finally mastered the pin mapping, and now each button corresponds to a different mode of flashing on your arm.

When the project was announced I knew I wanted to make something wearable with RGB LEDs. I started out thinking about making an armored gauntlet that glowed, but the idea soon grew into an entire shirt covered with LEDs. I bought a Lilypad Arduino from Sparkfun to control the LEDs, but realized too late that it did not have enough I/O pins to control all of them. Looking back I could have tried out individually addressable LEDs, but I think the ones I used look nicer.

Since my LEDs were not individually addressable this meant I needed a ton of I/O pins to control them. I had thirty LEDs on my strip and I cut it into ten short strips of three lights each. Five segments would go on each arm, and each segment needed four wires to control the lights. This meant I needed about 40 I/O pins just to power the LEDs, and not including the buttons I’d use to control them. My Arduino and Lilypad didn’t have nearly enough I/O pins, but my dad had a ChipKit Max 32 lying around from a previous project of his that he lent me. (He’s an electrical engineer at NASA so he often gets stuff like this for fun.) The ChipKit is a pretty amazing board. It has a whopping 83 I/O pins and built in Ethernet capabilities. Adafruit and Sparkfun don’t have them, but they can be ordered here:
http://www.digilentinc.com/Products/Catalog.cfm?NavPath=2,892&Cat=18
The data sheet that I referenced for the pin mapping is here:

It requires a different programming environment than Arduino, but it works in exactly the same way. Much like how Arduino is similar to Processing.

Each LED segment is soldered on to a piece of ribbon cable, which was easily attached to a 2×17 pin connector that could easily be plugged in and taken out from the ChipKit. Five of the ribbon cable wires needed to be dedicated to the button panels on the palms of the sleeves; 1 power, 1 ground, and 3 signal. The actual button panels were salvaged/cannibalized from a dead Sony VCR and came already-soldered with the correct resistors.

Unfortunately, Fritzing has no support for the ChipKit and doesn’t seem to know what ribbon cable is either. But here is a general idea of what the wiring for one arm would look like:

And an actual picture of the connectors to the ChipKit. The (barely visible) diodes are for providing the correct voltage drop when the LEDs are plugged in but unlit.

Sewing the shirt out of spandex only took me a few minutes, but attaching the LEDs to the sleeves took way longer. The stiff wires would stretch the fabric in ways that made it difficult to sew, and the adhesive on the back on the LED strips was no help whatsoever. In order to keep the pins on the bottom of the ChipKit from poking me in the back, and to make the garment (theoretically) washable I attached velcro to the bottom of the control board and stuck it to a panel of craft foam I sewed on to the back of the shirt.

Altogether, I’m really happy with how this project turned out. I learned a lot about pull-down resistors, pin mapping, and the wonders of ribbon cable. I also figured out how to sew a shirt out of spandex and learned a new soldering technique from my dad. The design of the electronics was well executed but I wish there was a better way of attaching the LEDs to the shirt because they stick out at awkward angles sometimes. I’m also really pleased with the way the light travels up and down the sleeves when the buttons are pressed. It would have been cool to use PWM to fade them, but there are only five PWM pins on the board. Not to mention that it would involve heavy alteration of my existing design to incorporate them.

I’ve been talking with a friend of mine about possibly getting a pair of these shirts exhibited in a rave runway fashion show he is planning. He’s very enthusiastic about featuring them and it’s an exciting idea, but if I were to do that I would have to think about streamlining the integration of the electronics into the fabric and deal with the issue of battery life. Currently this piece eats a 9V battery every 10 minutes or so when it’s not plugged in to the wall.

In the future I’d love to make more of these with higher durability and more light control options for performances and dancing.

Code

int ledString1L[] = {  // string 1 green/red/blue J3/J14
  44, 84, 83};
 
int ledString2L[] = {  // string 2 green/red/blue J3/J14
  13, 82, 12};
 
int ledString3L[] = {  // string 3 green/red/blue J3/J14
  11, 80, 10};
 
int ledString4L[] = {  // string 4 green/red/blue J3/J14
  9, 78, 8};
 
int ledString5L[] = {  // string 5 green/red/blue J3/J14
  7, 76, 6};
 
int ledString1R[] = {  // string 1 green/red/blue J8/J9
  23, 22, 25};
 
int ledString2R[] = {  // string 2 green/red/blue J8/J9
  30, 28, 29};
 
int ledString3R[] = {  // string 3 green/red/blue J8/J9
  31, 32, 33};
 
int ledString4R[] = {  // string 4 green/red/blue J8/J9
  35, 36, 37};
 
int ledString5R[] = {  // string 5 green/red/blue J8/J9
  39, 40, 41};
 
const int button1RPin = 53;
int button1RState = 0;
 
const int button2RPin = 52;
int button2RState = 0;
 
const int button3RPin = 51;
int button3RState = 0;
 
const int button1LPin = 70;
int button1LState = 0;
 
const int button2LPin = 0;
int button2LState = 0;
 
const int button3LPin = 1;
int button3LState = 0;
 
void setup() {                
  // initialize the digital pin as an output.
  int i;
  for (int i = 0; i < 3; i++) {
    pinMode(ledString1L[i], OUTPUT);  
    digitalWrite(ledString1L[i], HIGH);    // set the LED off
  }
  for (int i = 0; i < 3; i++) {
    pinMode(ledString2L[i], OUTPUT);  
    digitalWrite(ledString1L[i], HIGH);    // set the LED off
  }
  for (int i = 0; i < 3; i++) {
    pinMode(ledString3L[i], OUTPUT);  
    digitalWrite(ledString1L[i], HIGH);    // set the LED off
  }
  for (int i = 0; i < 3; i++) {
    pinMode(ledString4L[i], OUTPUT);  
    digitalWrite(ledString1L[i], HIGH);    // set the LED off
  }
  for (int i = 0; i < 3; i++) {
    pinMode(ledString5L[i], OUTPUT);  
    digitalWrite(ledString1L[i], HIGH);    // set the LED off
  }
  for (int i = 0; i < 3; i++) {
    pinMode(ledString1R[i], OUTPUT);  
    digitalWrite(ledString1L[i], HIGH);    // set the LED off
  }
  for (int i = 0; i < 3; i++) {
    pinMode(ledString2R[i], OUTPUT);  
    digitalWrite(ledString1L[i], HIGH);    // set the LED off
  }
  for (int i = 0; i < 3; i++) {
    pinMode(ledString3R[i], OUTPUT);  
    digitalWrite(ledString1L[i], HIGH);    // set the LED off
  }
  for (int i = 0; i < 3; i++) {
    pinMode(ledString4R[i], OUTPUT);  
    digitalWrite(ledString1L[i], HIGH);    // set the LED off
  }
  for (int i = 0; i < 3; i++) {
    pinMode(ledString5R[i], OUTPUT);  
    digitalWrite(ledString1L[i], HIGH);    // set the LED off
  }
  pinMode (button1RPin, INPUT);
  pinMode (button2RPin, INPUT);
  pinMode (button3RPin, INPUT);
 
  pinMode (button1LPin, INPUT);
  pinMode (button2LPin, INPUT);
  pinMode (button3LPin, INPUT);
 
}
void loop() {
  button1RState = digitalRead(button1RPin);
  if (button1RState == HIGH) {  
    int del=50;
    for (int i = 0; i++) {
      digitalWrite(ledString5R[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString5R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString4R[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString4R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString3R[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString3R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString2R[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString2R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1R[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString1R[i], HIGH);    // set the LED off
    }
  }
  else {
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString2R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString3R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3  ; i++) {
      digitalWrite(ledString4R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString5R[i], HIGH);    // set the LED off
    }
  }
button2RState = digitalRead(button2RPin);
  if (button2RState == HIGH) {  
    int del=50;
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1R[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString1R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString2R[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString2R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString3R[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString3R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString4R[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString4R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString5R[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString5R[i], HIGH);    // set the LED off
    }
  }
  else {
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString2R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString3R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3  ; i++) {
      digitalWrite(ledString4R[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString5R[i], HIGH);    // set the LED off
    }
  }
 button3RState = digitalRead(button3RPin);
  if (button3RState == HIGH) {  
    int del=10;
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1R[i], LOW);    // set the LED on
      delay(del); 
    digitalWrite(ledString1R[i], HIGH);
    }
  }
  else{
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1R[i], HIGH);    // set the LED off
    }
  }
button1LState = digitalRead(button1LPin);
  if (button1LState == HIGH) {  
    int del=50;
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1L[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString1L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString2L[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString2L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString3L[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString3L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString4L[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString4L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString5L[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString5L[i], HIGH);    // set the LED off
    }
  }
  else {
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString2L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString3L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString4L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString5L[i], HIGH);    // set the LED off
    }
  }
 
   button2LState = digitalRead(button2LPin);
  if (button2LState == HIGH) {  
    int del=50;
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString5L[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString5L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString4L[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString4L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString3L[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString3L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString2L[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString2L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1L[i], LOW);   // set the LED on
      delay(del);               // wait
      digitalWrite(ledString1L[i], HIGH);    // set the LED off
    }
  }
  else {
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString2L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString3L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString4L[i], HIGH);    // set the LED off
    }
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString5L[i], HIGH);    // set the LED off
    }
  }
 
  button3LState = digitalRead(button3LPin);
  if (button3LState == HIGH) {  
    int del=30;
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1L[i], LOW);    // set the LED on
      delay(del); 
    digitalWrite(ledString1L[i], HIGH);
    }
  }
  else{
    for (int i = 0; i<3; i++) {
      digitalWrite(ledString1L[i], HIGH);    // set the LED off
    }
  }
}

Post a comment