so..I;ve been playing around, and this is where I;ve got so far;
The idea was to see if I could make it wait 5 seconds, then start the led sequence for 30seconds, then switch off the leds and repeat the cycle, so wait another 5 seconds and start the cycle, Im getting somehwere but i know ive got into a muddle with the timers and need some steering if possible ![]()
Thank you!
const byte LedPins[5] = { 8, 9, 10, 11, 12};
unsigned long previousMillis;
unsigned long currentMillis = millis();
unsigned long previous30secondMillis;
int index = 0;
int updown = +1; // +1 or -1 for going left and right
boolean doBlink;
void setup()
{
for( auto a:LedPins)
pinMode( a, OUTPUT);
}
void loop ()
{
unsigned long currentMillis = millis();
if( currentMillis - previousMillis >= 5000)
{ doBlink = true;
}
if (doBlink) {
unsigned long currentMillis = millis();
if( currentMillis - previousMillis >= 80)
{
previousMillis = currentMillis;
digitalWrite( LedPins[index], LOW); // turn old led off
index += updown;
digitalWrite( LedPins[index], HIGH); // turn new led on
if( index <=0 || index >= 4)
updown = -updown;
}
}
if (doBlink && currentMillis - previous30secondMillis > 30000) {
doBlink = false;
}
}