int pinArray [] = {2,3,4,5,6,7,8,9,10,11,12,13 }; // Vector donde se van a declarar los LEDs
int waitStart= 200; // Tiempo entre encender un LED y otro
int tailLength = 4; // Numero de LEDs activos
int lineSize = 12; // Numero total de LEDs
void setup()
{
int i;
for (i=0; i< lineSize; i++)
{
pinMode(pinArray[i], OUTPUT);
}
}
void loop()
{
int i;
int tailCounter = tailLength; // I set up the tail length in a counter
for (i=0; i<lineSize; i++)
{
digitalWrite(pinArray[i],HIGH); // I light up consecutively the LEDs
delay(waitStart); // This time variable controles how fast I light them up
if (tailCounter == 0)
{
digitalWrite(pinArray[i-tailLength],LOW); // I turn off the LEDs depending on my tailLength
}
else
if (tailCounter > 0)
tailCounter--;
}
for (i=(lineSize-tailLength); i<lineSize; i++)
{
digitalWrite(pinArray[i],LOW); // I turn off the LEDs
delay(waitStart); // This time variable controles how fast I light them upm, and turn off as well
}
}