- Create a program that can make the Arduino flash a series of LEDs from side to side.
int led2 = 2;
int led3 = 3;
int led4 = 4;
int led5 = 5;
int led6 = 6;
int pause = 100;
void setup() {
// initialize the digital pin as an output.
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
}
void loop() {
digitalWrite(led2, HIGH);
delay(pause);
digitalWrite(led2, LOW);
delay(pause);
digitalWrite(led3, HIGH);
delay(pause);
digitalWrite(led3, LOW);
delay(pause);
digitalWrite(led4, HIGH);
delay(pause);
digitalWrite(led4, LOW);
delay(pause);
digitalWrite(led5, HIGH);
delay(pause);
digitalWrite(led5, LOW);
delay(pause);
digitalWrite(led6, HIGH);
delay(pause);
digitalWrite(led6, LOW);
delay(pause);
digitalWrite(led5, HIGH);
delay(pause);
digitalWrite(led5, LOW);
delay(pause);
digitalWrite(led4, HIGH);
delay(pause);
digitalWrite(led4, LOW);
delay(pause);
digitalWrite(led3, HIGH);
delay(pause);
digitalWrite(led3, LOW);
delay(pause);
}
In this lesson I learned several things:
Problems encountered:
You can do it, too! Sign up for free now at https://www.jimdo.com