prekid tipkalom
Diff: Interupt.cpp
- Revision:
- 0:11c592a697fb
diff -r 000000000000 -r 11c592a697fb Interupt.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Interupt.cpp Mon Feb 22 08:25:18 2021 +0000 @@ -0,0 +1,13 @@ +// toggle: + +#include "Interupt.h" + +Timer debounce; +int StartStop=1; +InterruptIn button(D3); + +void toggle() { +if (debounce.read_ms()>200) // only allow toggle if debounce timer has passed 200 ms + StartStop=!StartStop; + debounce.reset(); // restart timer when the toggle is performed +} \ No newline at end of file