Knight Rider LED Pattern With Arduino
4 Things You Need
- Arduino uno board
- 10 Led
- Resistors
- Jumper wires
void setup() {
// put your setup code here, to run once:
for ( int k=4; k < 14; k++){
pinMode(k , OUTPUT);
}
}
void loop() {
// put your main code here, to run repeatedly:
int t = 15;
for(int i= 4 ; i<14 ; i=i+1){
digitalWrite(i , HIGH);
delay(t);
digitalWrite(i+1 , HIGH);
delay(t);
digitalWrite(i+2 , HIGH);
delay(t);
digitalWrite(i , LOW);
delay(t);
digitalWrite(i+1 , LOW);
}
for(int i=13 ; i > 3; i--){
digitalWrite(i , HIGH);
delay(t);
digitalWrite(i-1 , HIGH);
delay(t);
digitalWrite(i-2 , HIGH);
delay(t);
digitalWrite(i , LOW);
delay(t);
digitalWrite(i-1 , LOW);
}
}
// put your setup code here, to run once:
for ( int k=4; k < 14; k++){
pinMode(k , OUTPUT);
}
}
void loop() {
// put your main code here, to run repeatedly:
int t = 15;
for(int i= 4 ; i<14 ; i=i+1){
digitalWrite(i , HIGH);
delay(t);
digitalWrite(i+1 , HIGH);
delay(t);
digitalWrite(i+2 , HIGH);
delay(t);
digitalWrite(i , LOW);
delay(t);
digitalWrite(i+1 , LOW);
}
for(int i=13 ; i > 3; i--){
digitalWrite(i , HIGH);
delay(t);
digitalWrite(i-1 , HIGH);
delay(t);
digitalWrite(i-2 , HIGH);
delay(t);
digitalWrite(i , LOW);
delay(t);
digitalWrite(i-1 , LOW);
}
}