Hi Guys... my first question to the forum yet surely not the last question that's already been asked... er... yea
Anyway... Suppose I have a string of LEDs that operate in a similar fashion to the Knight Rider or Cylon sequence... left to right or back and forth, whatever... rather than the loop beginning again immediately after cycling through the program, I need to be able to insert a delay of 10000ms or whatever at the end of the loop...
so...
Blinkety-Blinkety-Blinkety-PAUSE------Blinkety-Blinkety-Blinkety-PAUSE------Blinkety-Blinkety-Blinkety-PAUSE------etc
Here's my code as it is...
// setup function
//=======================================================================
void setup()
{
//set LEDs pin as output
pinMode(3,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
}
// variables
//=======================================================================
int LED1, LED2, LED3, LED4, LED5, LED6;
int counter;
// loop function
//=======================================================================
void loop()
{
//step 1 ===============================
counter=0; //counter counting 0 - 255
while(counter<255)
{
counter+=1;
LED1=counter; //increase current LED value
LED6=255-counter; //decrease previous LED value
analogWrite(3,LED1); //write LED values
analogWrite(11,LED6);
delay(1); //1ms delay
}
//step 2 ===============================
counter=0; //counter counting 0 - 255
while(counter<255)
{
counter+=1;
LED2=counter; //increase current LED value
LED1=255-counter; //decrease previous LED value
analogWrite(5,LED2); //write LED values
analogWrite(3,LED1);
delay(1); //1ms delay
}
//step 3 ===============================
counter=0; //counter counting 0 - 255
while(counter<255)
{
counter+=1;
LED3=counter; //increase current LED value
LED2=255-counter; //decrease previous LED value
analogWrite(6,LED3); //write LED values
analogWrite(5,LED2);
delay(1); //1ms delay
}
//step 4 ===============================
counter=0; //counter counting 0 - 255
while(counter<255)
{
counter+=1;
LED4=counter; //increase current LED value
LED3=255-counter; //decrease previous LED value
analogWrite(9,LED4); //write LED values
analogWrite(6,LED3);
delay(1); //1ms delay
}
//step 5 ===============================
counter=0; //counter counting 0 - 255
while(counter<255)
{
counter+=1;
LED5=counter; //increase current LED value
LED4=255-counter; //decrease previous LED value
analogWrite(10,LED5); //write LED values
analogWrite(9,LED4);
delay(1); //1ms delay
}
//step 6 ===============================
counter=0; //counter counting 0 - 255
while(counter<255)
{
counter+=1;
LED6=counter; //increase current LED value
LED5=255-counter; //decrease previous LED value
analogWrite(11,LED6); //write LED values
analogWrite(10,LED5);
delay(1); //1ms delay
}
}
So... at the end of STEP 6 - or before Step 1 starts again - I want the loop to stop running for 1 or 2 seconds...
I'm pulling my hair out guys... your help is MUCH appreciated.