Knight Rider
--------------------------- Copy Code Below
void setup()
{
{
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
}
void loop()
{
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
delay(1000);
digitalWrite(12, LOW);
digitalWrite(11, HIGH);
delay(1000);
digitalWrite(11, LOW);
digitalWrite(10, HIGH);
delay(1000);
digitalWrite(10, LOW);
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
digitalWrite(8, HIGH);
delay(1000);
digitalWrite(9, HIGH);
digitalWrite(8, LOW);
delay(1000);
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
delay(1000);
digitalWrite(10, LOW);
digitalWrite(11, HIGH);
delay(1000);
digitalWrite(11, LOW);
digitalWrite(12, HIGH);
delay(1000);
digitalWrite(12, LOW);
}
--------------------------- Copy Code above
Going Further:
1) Control the delay using a variable instead of a literal
2) Use an array to address output pins instead literal pin numbers
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
}
void loop()
{
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
delay(1000);
digitalWrite(12, LOW);
digitalWrite(11, HIGH);
delay(1000);
digitalWrite(11, LOW);
digitalWrite(10, HIGH);
delay(1000);
digitalWrite(10, LOW);
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
digitalWrite(8, HIGH);
delay(1000);
digitalWrite(9, HIGH);
digitalWrite(8, LOW);
delay(1000);
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
delay(1000);
digitalWrite(10, LOW);
digitalWrite(11, HIGH);
delay(1000);
digitalWrite(11, LOW);
digitalWrite(12, HIGH);
delay(1000);
digitalWrite(12, LOW);
}
--------------------------- Copy Code above
Going Further:
1) Control the delay using a variable instead of a literal
2) Use an array to address output pins instead literal pin numbers
No comments:
Post a Comment