int LEDpins[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
//global variable array to assign each of the LEDs to a pin
int ledCount = 10; //initiailising for use in the for loop
//use a for loop to setup each LED to maximise code efficiency
void setup() {
for (int thisLED = 0; thisLED < ledCount; thisLED++){
pinMode(LEDpins[thisLED], OUTPUT); //thisLED is used as an array index for ledPins
}
//Turn off all the LED pins
for (int thisLED = 0; thisLED < ledCount; thisLED++){
digitalWrite(LEDpins[thisLED], LOW);
}
}
void loop() {
//Turn on all the LEDs
for (int thisLED = 0; thisLED < ledCount; thisLED++){
digitalWrite(LEDpins[thisLED], HIGH);
delay(100);
}
}