I've always wanted to build a Knight Rider style LED array (minus the swoosh sound). It just so happens that a few months ago I ordered an arduino. I finally assembled the "proto shield" for it, and one of the first things I wanted to test out is if I can make something like this. I'm pleased to report it took about an hour of hacking and it works. Check out the video.
Schematic

Parts List
- 1 x Arduino
- 5 x Red LED's
- 5 x 1k ohm (1/4 watt) Resistors
- 16 guage insolated solid copper wire (about 6 inches will do, you'll also probably need some wire strippers and side cutters)
Code
I think the following code could be optimized a lot. However the whole purpose of this experiment was to test if something like this is quick and relatively easy to hack up.
/*
* Knight Rider
*
* Ever watch Knight Rider? Yes that 80's show with that awesome car named Kit?
*
* Want that same effect for your car?
*
* Here it is.
*
* created 28 August 2010
* by Nicholas Granado
*
*/
int DELAY = 100;
int LONG_DELAY = 500;
int MODE = 0;
int START = 9;
int LENGTH = 14;
// PINS: 0 1 2 3 4 5 6 7 8 9 0 1 2 3
int state[] = {0,0,0,0,0,0,0,0,0,1,0,0,0,0};
int pin;
void setup() {
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
}
void load_pin_state() {
for(pin = START; pin < LENGTH; pin++) {
if(state[pin] == 0) {
digitalWrite(pin, LOW);
}
else if(state[pin] == 1) {
digitalWrite(pin, HIGH);
}
}
if(state[START] == 1 || state[LENGTH - 1] == 1) {
delay(LONG_DELAY);
} else {
delay(DELAY);
}
}
void loop()
{
load_pin_state();
if(MODE == 0) {
for(pin = START; pin < LENGTH; pin++) {
if(state[pin] == 1) {
state[pin] = 0;
state[pin + 1] = 1;
if((pin + 1) == (LENGTH - 1)) {
MODE = 1;
}
break;
}
} // end for loop
} else {
for(pin = LENGTH - 1; pin >= START; pin--) {
if(state[pin] == 1) {
state[pin] = 0;
state[pin - 1] = 1;
if((pin - 1) == START){
MODE = 0;
}
break;
}
} // end for loop
}// end mode
}
Summary
The arduino hardware platform makes building circuits and interfacing them with a micro-controller fun. My next goal is to build something a bit more complicated and useful.
feed
