I don't know these lessons, but I think this code is close from what you need :
bool buttonPressed = false;
long lastLed1Blink = 0, lastLed2Blink = 0
int led1Delay = 100, led2Delay =200;
void loop() {
while(!buttonPressed) {
if (millis()>(lastLed1Blink+led1Delay) { /* Make led1 blink */ }
if (millis()>(lastLed2Blink+led2Delay) { /* Make led2 blink */ }
/* Add code here to check if button is pressed, including debouncing it */
}
/* Add code here to change led2 blink rate */
}
There are certainly cleaner ways to do this, including timer-based interrupts (If they're available on the Arduino, dunno). You might also want to add something like :
if (millis() < lastLed1Blink) { lastLed1Blink = 0; lastLed2Blink = 0; }
To prevent the overflow, then reset, of the returned value of millis() every 9 hours or something.
... I hope this is answering your question. If not, I'd try to give you another way... I have time to spend, just watching scripts run ![]()