Help with Arrays and LEDs

Hello, I am a beginner on arduino uno. I am creating an LED sequence from 100000,110000 111000 to 111111. I managed to do that but I am trying to make the code smaller by using for loops and arrays whereas before i wrote a very basic, very long program. I have managed to use for loops and arrays to assign pins to LEDs but I am stuck on the sequence part in the void loop. Like I mentioned, I can do the sequence the long way e.g digitalWrite(ledPin1,HIGH) etc.
I would appreciate if anyone can help me out.

int ledPin = {13,12,11,10,9,8};
int timeInterval = 500;

void setup() {
for(int i = 1; i<7;i++)
{ pinMode (ledPin*,OUTPUT);}*
for(int i = 1; i<7;i++)
{ digitalWrite (ledPin*,LOW);}*
}
void loop() {
}

First, the binary values you listed don’t correspond to the LED’s you have in the array, but that probably doesn’t matter. Second, you should have a 200 to 400 ohm resistor in line with each LED because the Arduino can’t sink too much current. Third, you need to adjust the code such that:

void setup() {
 for(int i = 0; i < 6;i++)
 { pinMode (ledPin[i],OUTPUT);}


 for(int i = 0; i < 6;i++)
 { digitalWrite (ledPin[i],LOW);}

}

Arrays start with element 0, not 1. So, on the first pass through the loop, it will be:

  • digitalWrite(ledPin[0], OUTPUT);*

which is actually:

digitalWrite(13, OUTPUT);

From this you should be able to write a loop that turns the LED’s on and off with a sequence of digitalWrite()'s and delay()'s. Finally, make sure you use code tags when you post code. The posts at the top of the Forum by Nick Gammon will tell you how.

Thank you very much for your help :)