Simple Debouncing library and sample code.
Dependencies: DebouncedIn mbed
main.cpp
- Committer:
- SIT2016
- Date:
- 2016-06-12
- Revision:
- 1:3f6f29315707
- Parent:
- 0:4b63a4c5ed47
- Child:
- 2:e7f390d1e86c
File content as of revision 1:3f6f29315707:
#include "mbed.h" #include "DebouncedIn.h" DigitalOut led(LED1); //red led DebouncedIn button(PTC9); //switch int main() { while(1) { //using library directly /*if (button.rising()){ //execute only if rising edge detected on the button. led = !led; }*/ //without library if(button == 0) { //detecting press led = !led; while(button==0); //empty while to wait while switch is pressed. hence toggling only once. } } }