void ISR_Bp1(void) { static unsigned int lastPress = 0; // Check if the button has been pressed if (!PIO_Get(&pinPB1)) { // Simple debounce method: limit push frequency to 1/DEBOUNCE_TIME // (i.e. at least DEBOUNCE_TIME ms between each push) if ((timestamp - lastPress) > DEBOUNCE_TIME) { lastPress = timestamp; // Toggle LED state pLedStates[0] = !pLedStates[0]; if (!pLedStates[0]) { LED_Clear(0); } } } }