This is a simple "Knight Rider" LED scanner that you can adjust the speed of easily. A great first or second project.
Basically, you use the breadboard to set up your 10 LEDs (choose your favorite color. Connect the + post of the LED to the first 10 pins of the Arduino. Hook the GROUND of the Arduino to the bus of the breadboard (usually blue) and jumper the negative peg of the LED to that bus with a short wire.
Then, you simply cut and paste the code to turn the lights on (and off) in sequence. A variable, "a", adjusts the delay which controls how fast the lights move. Simply change the value of a to make the scanner faster or slower.
NOTE: 1982 Pontiac Trans Am is not included in this project, but would be an optional (and amazing) upgrade.
int a=1000;
int b=0;
void setup() {
// put your setup code here, to run once:
pinMode(1,OUTPUT);
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(1,HIGH);
delay(a);
digitalWrite(1,LOW);
digitalWrite(2,HIGH);
delay(a);
digitalWrite(2,LOW);
digitalWrite(3,HIGH);
delay(a);
digitalWrite(3,LOW);
digitalWrite(4,HIGH);
delay(a);
digitalWrite(4,LOW);
digitalWrite(5,HIGH);
delay(a);
digitalWrite(5,LOW);
digitalWrite(6,HIGH);
delay(a);
digitalWrite(6,LOW);
digitalWrite(7,HIGH);
delay(a);
digitalWrite(7,LOW);
digitalWrite(8,HIGH);
delay(a);
digitalWrite(8,LOW);
digitalWrite(9,HIGH);
delay(a);
digitalWrite(9,LOW);
digitalWrite(10,HIGH);
delay(a);
digitalWrite(10,LOW);
digitalWrite(9,HIGH);
delay(a);
digitalWrite(9,LOW);
digitalWrite(8,HIGH);
delay(a);
digitalWrite(8,LOW);
digitalWrite(7,HIGH);
delay(a);
digitalWrite(7,LOW);
digitalWrite(6,HIGH);
delay(a);
digitalWrite(6,LOW);
digitalWrite(5,HIGH);
delay(a);
digitalWrite(5,LOW);
digitalWrite(4,HIGH);
delay(a);
digitalWrite(4,LOW);
digitalWrite(3,HIGH);
delay(a);
digitalWrite(3,LOW);
digitalWrite(2,HIGH);
delay(a);
digitalWrite(2,LOW);
//experimental speed section
// int b=b-20;
//a=a-b;
//if (a=0)
//{
// a=1000;
// }
//if (b=800)
//{
// b=0;
//}
}




_ztBMuBhMHo.jpg?auto=compress%2Cformat&w=48&h=48&fit=fill&bg=ffffff)

Comments