Sakis Kasampalis
/
two-way-switch
toggle button style
two_way_switch.cpp
- Committer:
- faif
- Date:
- 2015-03-15
- Revision:
- 0:ccd27d3bca28
File content as of revision 0:ccd27d3bca28:
#include "mbed.h" #include "two_way_switch.h" int main (void) { DigitalOut state = myled; while (true) { if (button) { /* toggle the state of the led */ toggle_state(state); /* to avoid the bouncing effect */ while (button) { wait(BOUNCE_DELAY); } } } } void toggle_state(DigitalOut& s) { switch(s) { case true: s = false; break; case false: s = true; break; } }