volatile unsigned long lastButtonPress = millis(); void initButton() { pinMode(BUTTON_PIN, INPUT_PULLUP); // Order of ISRs matter: RISING should be invoked first attachInterrupt(digitalPinToInterrupt(BUTTON_PIN), buttonISRtime, CHANGE); attachInterrupt(digitalPinToInterrupt(BUTTON_PIN), buttonISRstate, RISING); } void buttonISRstate() { if ((millis() - lastButtonPress) > 100) { if (countdown < 0) countdown = 0; else if (countdown == 0) countdown = COUNTDOWN; else { countdown = -1; digitalWrite(BUTTON_LED_PIN, LOW); } } } void buttonISRtime() { lastButtonPress = millis(); }