//LED Pin Variables int ledPins[] = {2,3,4,5,6,7,8,9}; //An array to hold the pin each LED is connected to void setup() { //Set each pin connected to an LED to output mode (pulling high (on) or low (off) for(int i = 0; i < 8; i++){ //this is a loop and will repeat eight times pinMode(ledPins[i],OUTPUT); //we use this to set each LED pin to output } } void loop() // run over and over again { int delayTime = 100; //the time (in milliseconds) to pause between LEDs //make smaller for quicker switching and larger for slower //Turn Each LED on one after another for(int i = 0; i <= 7; i++){ digitalWrite(ledPins[i], HIGH); //Turns on LED #i each time this runs i delay(delayTime); //gets one added to it so this will repeat } //8 times the first time i will = 0 the final //time i will equal 7; //Turn Each LED off one after another for(int i = 7; i >= 0; i--){ //same as above but rather than starting at 0 and counting up //we start at seven and count down digitalWrite(ledPins[i], LOW); //Turns off LED #i each time this runs i delay(delayTime); //gets one subtracted from it so this will repeat } //8 times the first time i will = 7 the final //time it will equal 0 }