Simple Debouncing library and sample code.
Dependencies: DebouncedIn mbed
main.cpp@0:4b63a4c5ed47, 2016-06-05 (annotated)
- Committer:
- SIT2016
- Date:
- Sun Jun 05 13:12:33 2016 +0000
- Revision:
- 0:4b63a4c5ed47
- Child:
- 1:3f6f29315707
Simple debouncing library and sample code.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
SIT2016 | 0:4b63a4c5ed47 | 1 | #include "mbed.h" |
SIT2016 | 0:4b63a4c5ed47 | 2 | #include "DebouncedIn.h" |
SIT2016 | 0:4b63a4c5ed47 | 3 | |
SIT2016 | 0:4b63a4c5ed47 | 4 | DigitalOut led(PTA5); //red led |
SIT2016 | 0:4b63a4c5ed47 | 5 | DebouncedIn button(PTC9); //switch |
SIT2016 | 0:4b63a4c5ed47 | 6 | |
SIT2016 | 0:4b63a4c5ed47 | 7 | int main() { |
SIT2016 | 0:4b63a4c5ed47 | 8 | while(1) { |
SIT2016 | 0:4b63a4c5ed47 | 9 | if (button.rising()){ //execute only if rising edge detected on the button. |
SIT2016 | 0:4b63a4c5ed47 | 10 | led = !led; |
SIT2016 | 0:4b63a4c5ed47 | 11 | } |
SIT2016 | 0:4b63a4c5ed47 | 12 | } |
SIT2016 | 0:4b63a4c5ed47 | 13 | } |
SIT2016 | 0:4b63a4c5ed47 | 14 |