void pushButton() { static unsigned long last_interrupt_time = 0; unsigned long interrupt_time = millis(); // If interrupts come faster than 200ms, assume it's a bounce and ignore if (interrupt_time - last_interrupt_time > 200) { Serial.print("Switching mode to MODE_COUNTING\n"); mode = MODE_COUNTING; recordedTimes = 0; showShape(2); showShapeLAP(2); } last_interrupt_time = interrupt_time; }