pushButton.ino 462 B

12345678910111213141516
  1. void pushButton()
  2. {
  3. static unsigned long last_interrupt_time = 0;
  4. unsigned long interrupt_time = millis();
  5. // If interrupts come faster than 200ms, assume it's a bounce and ignore
  6. if (interrupt_time - last_interrupt_time > 200)
  7. {
  8. Serial.print("Button\n");
  9. if (mode == MODE_SPINUP) {
  10. Serial.print("Switching mode to MODE_COUNTING\n");
  11. mode = MODE_COUNTING;
  12. recordedLaps = 0;
  13. }
  14. }
  15. last_interrupt_time = interrupt_time;
  16. }