//https://docs.arduino.cc/built-in-examples/control-structures/Arrays/
//https://docs.arduino.cc/built-in-examples/control-structures/Arrays/
int timer = 100;
int ledPins[] = {
2,3,4,5,6,7
};
int pinCount = 6;
void setup() {
// the array of elements are numbered from 0 to (pinCount - 1)
for (int thisPin = 0; thisPin < pinCount; thisPin++)
pinMode(ledPins[thisPin], OUTPUT);
}
void loop() {
// loop from low->highest pin
for(int thisPin = 0; thisPin < pinCount; thisPin++){
//turn pin on:
digitalWrite(ledPins[thisPin], HIGH);
delay(timer);
//turn pin off
digitalWrite(ledPins[thisPin], LOW);
}
//loop from highest->lowest pin:
for(int thisPin = pinCount -1; thisPin >= 0; thisPin --){
//turn pin on:
digitalWrite(ledPins[thisPin], HIGH);
delay(timer);
//turn pin off:
digitalWrite(ledPins[thisPin], LOW);
}
}