Flashing LEDs on a baseball cap

With the ABQ Maker Faire around the corner, I thought it would be neat to dress up for the occasion. Since I had an Arduino Lilypad sitting around, making a flashing LED hat sounded like a good idea. Starting with one of my new Avocado Electronics baseball caps and a bunch of LEDs and resistors, I went to work.

 Raw materials: LEDs, resistors, and wire. Raw materials: LEDs, resistors, and wire.

At the top of the hat are six tiny holes. Each one is the perfect size to fit a single 3mm LED through it. My first step was to solder six individual circuits each consisting of one LED, one resistor, and ample wire. After soldering these together and keeping close track of polarity, I installed the lights into the hat and ran the wiring to the back.

 Lights installed and wire routed to the back of the hat Lights installed and wire routed to the back of the hat

In the back, all the wires are routed to a Lilypad Arduino. I know that I could have used conductive thread, but I wanted this hat to look like a real hack job.

 Back of hat Back of hat

At the back of the hat is an Arduino Lilypad. Each light is attached to a separate pin. The setup is powered by Sparkfun’s Lilypad power source. It steps up a 1.5V AA battery to 5V for the Lilypad.

 Arduino Lilypad Arduino Lilypad  Lilypad power source Lilypad power source

Here is the code I used in the Arduino to make it work. This code randomly turns the lights on and off.

char light[] = {5, 6, 7, 9, 10, 11}; char crazy[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
void setup() { 
 for (int x=0; x< 6;x++) { 
  pinMode(light[x], OUTPUT); 
  digitalWrite(light[x], 0); 
} 
 }

void loop() { 
 crazy[0] = random(0,2); 
 crazy[1] = random(0,2); 
 crazy[2] = random(0,2); 
 crazy[3] = random(0,2); 
 crazy[4] = random(0,2); 
 crazy[5] = random(0,2); 
 for (int x=0; x<6; x++) { 
  digitalWrite(light[x], crazy[x]); 
  } 
 delay(200); 
 }

Finally, here is what it looks like now.

 

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s