Hopefully just using lots of comments will help. A couple of possible errors in your code where the first and last LED will not turn on/off
int timer = 300; // Delay time between LED turning on/off
int led[] = { 3, 4, 5, 6, 7, 8, 9, 10 }; // Array of arduino pins the leds are connected to
int pinCount = 8; // The number of LED's connected to pins
void setup()
{
for(int i = 0; i < pinCount; i++) // Loop through array from 0 to pinCount-1
{
pinMode(led[i], OUTPUT); // Setting each pin to output
}
}
void loop()
{
for(int i = 0; i < pinCount-1; i++) // Loop through array from 0 to pinCount-2 (Should be i < pinCount)
{
digitalWrite( led[i],HIGH); // Turn LED i on
delay(timer); // Delay a bit
digitalWrite( led[i],LOW); // Turn LED i off
delay(timer); // Delay a bit
digitalWrite( led[i],HIGH); // Turn LED i on
delay(timer); // Delay a bit
digitalWrite( led[i],LOW); // Turn LED i off
delay(timer); // Delay a bit
} // Back for next i
{ // Not needed
for(int i = pinCount-1; i > 0; i--) // Loop through array from pinCount-1 to 1 (Should be i >= 0)
{
digitalWrite( led[i],HIGH); // Turn LED i on
delay(timer); // Delay a bit
digitalWrite( led[i],LOW); // Turn LED i off
delay(timer); // Delay a bit
digitalWrite( led[i],HIGH); // Turn LED i on
delay(timer); // Delay a bit
digitalWrite( led[i],LOW); // Turn LED i off
delay(timer); // Delay a bit
} // Back for next i
} // Not needed
} // Back to loop start