// Define the number of LEDs
const int numLEDs = 3;
int i = 0;
// Create an array to hold the LED pin numbers
int ledPins[numLEDs] = {3, 4, 5};
void setup() {
// Set each LED pin as an output
for ( i = 0; i < numLEDs; i++) {
pinMode(ledPins[i], OUTPUT);
}
}
void loop() {
/* Turn on each LED in sequence
for (initialization; condition; increment) {
Code to be executed in each iteration
}
*/
for ( i = 0; i < numLEDs; i++) {
digitalWrite(ledPins[i], HIGH); // Turn on the LED
delay(500); // Wait for half a second
digitalWrite(ledPins[i], LOW); // Turn off the LED
}
}