Can somebody please point out what I am missing to make this sequence work? The aim is to
- push a button. redStart remembers what the time is.
- this button push also turns 7 LEDs off and 2 red LEDs on
- after the stated interval, the 2 red LEDs go off and the first of 7 turns on.
- after the second stated interval, the next of the 7 turns on,
- and so forth until all 7 are restored to their original ON state.
The currentMillis() is never updated, so the original 'snapshot' of the time recorded should just increase, right? I don't want this to be a loop, after the last of the group of 7 comes on, the function waits to repeat itself with the next button press.
In this part of the sketch (there is a lot more that does not cross over with this sequence), when the button is pressed, only the first thing happens (7 off, 2 on). and then it sits.
What am I missing/forgetting/not understanding? I am using the "Button" library that comes with arduino . I have tried it the traditional way as well, but this is not the issue.
I eventually want to put the interval times in an array and tidy this up, but one thing at a time. Here it is. The answer is probably staring me in the face.
/*
this is just a part of a bigger sketch, all of which works great. I have only included this portion that I cannot get to work because I am a dufus
unsigned long redStart = 0; // Time when Red Alert started
const unsigned long eventInterval0 = 10000;
const unsigned long eventInterval1 = 11000;
const unsigned long eventInterval2 = 13000;
const unsigned long eventInterval3 = 15000;
const unsigned long eventInterval4 = 18000;
const unsigned long eventInterval5 = 20000;
const unsigned long eventInterval6 = 22000;
const unsigned long eventInterval7 = 24000;
const unsigned long eventInterval8 = 26000;*/
// I call this function in a main sketch, as I do with two other functions
// "if(button.isPressed()){ FN_redAlert}"
void FN_redAlert() {
{
Serial.println("The button is pressed");
redStart == millis();
Serial.println("RED ALERT!");
}
if (redStart <= eventInterval0) {
for (int i; i < 8; i++) { //red alert lights on, spotlights off
digitalWrite(dryDock[i], LOW);
digitalWrite(redPin1, HIGH);
digitalWrite(redPin2, HIGH);
} // this is all that works.
if (redStart >= eventInterval1) { // red alert finishes, first spotlight set turns on
Serial.println("Ice Ice Baby1"); //I got this from a tutorial on millis(). It just kinda stuck
digitalWrite(dryDock[0], HIGH); //first light group of the sequence
digitalWrite(redPin1, LOW); //red lights go off
digitalWrite(redPin2, LOW);
}
if (redStart >= eventInterval2) { //second spotlight group turns on
Serial.println("Ice Ice Baby2");
digitalWrite(dryDock[1], HIGH);
}
if (redStart >= eventInterval3) { //third spotlight group turns on
Serial.println("Ice Ice Baby3");
digitalWrite(dryDock[2], HIGH);
}
if (redStart >= eventInterval4) { //fourth spotlight group turns on
Serial.println("Ice Ice Baby4");
digitalWrite(dryDock[3], HIGH);
}
if (redStart >= eventInterval5) { //fifth spotlight group turns on
Serial.println("Ice Ice Baby5");
digitalWrite(dryDock[4], HIGH);
}
if (redStart >= eventInterval6) { //six spotlight group turns on
Serial.println("Ice Ice Baby6");
digitalWrite(dryDock[5], HIGH);
}
if (redStart >= eventInterval7) { //seventh and last spotlight group turns on
Serial.println("Ice Ice Baby7");
digitalWrite(dryDock[6], HIGH);
Serial.println("end");
}
}
} // end of function- waits for another button press.
Thanks.



