prekid tipkalom

Committer:
atopcic
Date:
Mon Feb 22 08:25:18 2021 +0000
Revision:
0:11c592a697fb
prekid tipkalom

Who changed what in which revision?

UserRevisionLine numberNew contents of line
atopcic 0:11c592a697fb 1 // toggle:
atopcic 0:11c592a697fb 2
atopcic 0:11c592a697fb 3 #include "Interupt.h"
atopcic 0:11c592a697fb 4
atopcic 0:11c592a697fb 5 Timer debounce;
atopcic 0:11c592a697fb 6 int StartStop=1;
atopcic 0:11c592a697fb 7 InterruptIn button(D3);
atopcic 0:11c592a697fb 8
atopcic 0:11c592a697fb 9 void toggle() {
atopcic 0:11c592a697fb 10 if (debounce.read_ms()>200) // only allow toggle if debounce timer has passed 200 ms
atopcic 0:11c592a697fb 11 StartStop=!StartStop;
atopcic 0:11c592a697fb 12 debounce.reset(); // restart timer when the toggle is performed
atopcic 0:11c592a697fb 13 }