animations of lights

Hi! :slight_smile:
I've just received my arduino and after a couple of tutorials, i tried to power up a line of 6 lights (one light at a time) from left to right 1-2-3-4-5-6. This went on fine, but now, I'd like to do the same, but starting with the second light, then the third, etc.
Wich means first 1-2-3-4-5-6, then 2-3-4-5-6, then 3-4-5-6, then 4-5-6, then 5-6, then 6 then go back to start of the program. I know i can do it like this :

int i;

for (i = 0; i< lineSize; i ++)
{
digitalWrite(pinArray*, HIGH);*

  • delay(100);*
    _ digitalWrite(pinArray*, LOW);_
    _
    }_
    _
    for (i = 1; i< lineSize; i ++)_
    _
    {_
    _ digitalWrite(pinArray, HIGH);
    delay(100);
    digitalWrite(pinArray, LOW);
    }
    for (i = 2; i< lineSize; i ++)
    {
    digitalWrite(pinArray, HIGH);
    delay(100);
    digitalWrite(pinArray, LOW);
    }*

    etc...
    But I'm looking for a simpler way. Do you know if it's possible and how?_

Hi Georges

something like that :wink:

int i; 
int j;
for (j=0; j<lineSize-1; j++) {
  for (i = j;  i< lineSize; i ++) 
  { 
    digitalWrite(pinArray[i], HIGH); 
    delay(100); 
    digitalWrite(pinArray[i], LOW); 
  }  
}

regards

eric

Thank you! :slight_smile: