volatile unsigned long lastButtonPress = millis(); // Debouncing na timerze: // https://github.com/khoih-prog/TimerInterrupt/blob/master/examples/SwitchDebounce/SwitchDebounce.ino 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(); }