Not totally sure how you want the LEDs to turn off again but take a look at this:
/*Alittle something for my dad's H0 modeltrain
*this is the light for a swing from the '50s
*based on a 8 LED kit from some web retailer.
*the code is simple, as were the Tivoli light in the '50s
*/
//LED Pin Variables
int ledPins[] = {2,3,4,5,6,7,8,9,10,11}; //An array to hold the pin each LED is connected to
//i.e. LED #0 is connected to pin 2, LED #1, 3 and so on
//to address an array use ledPins[0] this would equal 2
//and ledPins[9] would equal 11
/*
* setup() - this function runs once when you turn your Arduino on
* We the three control pins to outputs
*/
void setup()
{
//Set each pin connected to an LED to output mode (pulling high (on) or low (off)
for(int i = 0; i < 10; i++){ //this is a loop and will repeat ten times
pinMode(ledPins[i],OUTPUT); //we use this to set each LED pin to output
} //the code this replaces is below
/* (commented code will not run)
* these are the lines replaced by the for loop above they do exactly the
* same thing the one above just uses less typing
pinMode(ledPins[0],OUTPUT);
pinMode(ledPins[1],OUTPUT);
pinMode(ledPins[2],OUTPUT);
pinMode(ledPins[3],OUTPUT);
pinMode(ledPins[4],OUTPUT);
pinMode(ledPins[5],OUTPUT);
pinMode(ledPins[6],OUTPUT);
pinMode(ledPins[7],OUTPUT);
pinMode(ledPins[8],OUTPUT);
pinMode(ledPins[9],OUTPUT);
(end of commented code)*/
}
/*
* loop() - this function will start after setup finishes and then repeat
* we call a function called oneAfterAnother().
*/
void loop() // run over and over again
{
oneAfterAnotherLoop();
}
void oneAfterAnotherLoop(){
int delayTime = 350; //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 <= 9; 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 = 9; 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
}
Hope that it can help you a little...