Simple Debouncing library and sample code.
Dependencies: DebouncedIn mbed
main.cpp@2:e7f390d1e86c, 2016-06-14 (annotated)
- Committer:
- SIT2016
- Date:
- Tue Jun 14 07:20:02 2016 +0000
- Revision:
- 2:e7f390d1e86c
- Parent:
- 1:3f6f29315707
Removed manual debonce
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 | 1:3f6f29315707 | 4 | DigitalOut led(LED1); //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 | 1:3f6f29315707 | 9 | //using library directly |
SIT2016 | 2:e7f390d1e86c | 10 | if (button.rising()){ //execute only if rising edge detected on the button. |
SIT2016 | 0:4b63a4c5ed47 | 11 | led = !led; |
SIT2016 | 0:4b63a4c5ed47 | 12 | } |
SIT2016 | 0:4b63a4c5ed47 | 13 | } |
SIT2016 | 0:4b63a4c5ed47 | 14 | } |
SIT2016 | 0:4b63a4c5ed47 | 15 |