Sakis Kasampalis
/
timed-switch
Timed switch
timed_switch.cpp
- Committer:
- faif
- Date:
- 2012-02-11
- Revision:
- 0:5d9b6304f982
- Child:
- 1:a523eaac3b7c
File content as of revision 0:5d9b6304f982:
#include "mbed.h" #include "timed_switch.h" int main (void) { t.start (); while (True) { if (True == button) { // start counting time when the button is pressed t.reset (); // debouncing while (True == button) { wait (wait_time); } // remove the debouncing delay from the counted time button_holded = t.read_ms () - time_correction; /* start couting time again and flashing the LED after the button is released */ t.reset (); while (t.read_ms () < button_holded) { myled = LedOn; wait (wait_on); myled = LedOff; wait (wait_off); } } } }