Introduction: Knight Rider Lilypad
A long time ago, I did this Project, was with a small board that only had 3 ports. Finally I got my Lilypad to work, so decided to make the Knight Rider with all 12 LEDs.
There are a couple of ways to write the code, from manual telling the board to turn one led on, wait turn in off and progress, or a more automated one. You have 3 exemples in the arduino tutorial page
Step 1: Code and Sewing
Since I wanted to use 12 leds ... this is the code:
int pinArray[] = {2, 3, 4, 5, 6, 7,8,9,10,11,12,13}; int count = 0; int timer = 100;
void setup() { { pinMode(pinArray[count], OUTPUT);} } void loop() { for (count=0;count<14;count++) { digitalWrite(pinArray[count], HIGH); delay(timer); digitalWrite(pinArray[count], LOW); delay(timer); } for (count=13;count>=0;count--) { digitalWrite(pinArray[count], HIGH); delay(timer); digitalWrite(pinArray[count], LOW); delay(timer); } }
I decided to use the wire to fix the + led side to the arduino lilyad, and sew only the - led side between them all and the board.
(warning! check the leds individually ... I did all the work, and led 7 and 8 were broken, so I ended up using a normal led on top of the wearable led, else I had to perform major surgery on my project )