//LED Pin Variables int ledPins[] = {2,3,4,5,6,7,8,9}; void setup() { 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 for(int i = 0; i <= 7; i++){ int offLED = i - 1; //Calculate which LED was turned on last time through if(i == 0) { //for i = 1 to 7 this is i minus 1 (i.e. if i = 2 we will offLED = 7; //turn on LED 2 and off LED 1) } //however if i = 0 we don't want to turn off led -1 (doesn't exist) //instead we turn off LED 7, (looping around) digitalWrite(ledPins[i], HIGH); //turn on LED #i digitalWrite(ledPins[offLED], LOW); //turn off the LED we turned on last time delay(delayTime); } }