Timed switch

Dependencies:   mbed

Committer:
faif
Date:
Sun Mar 15 17:19:54 2015 +0000
Revision:
1:a523eaac3b7c
Parent:
0:5d9b6304f982
revised

Who changed what in which revision?

UserRevisionLine numberNew contents of line
faif 0:5d9b6304f982 1 #ifndef TIMED_SWITCH_H
faif 0:5d9b6304f982 2 #define TIMED_SWITCH_H
faif 0:5d9b6304f982 3
faif 0:5d9b6304f982 4 enum {LedOff = 0, LedOn = 1};
faif 1:a523eaac3b7c 5
faif 1:a523eaac3b7c 6 const float WAIT_TIME = 0.2; // to avoid bouncing
faif 1:a523eaac3b7c 7 const float WAIT_ON = 0.5;
faif 1:a523eaac3b7c 8 const float WAIT_OFF = 0.5;
faif 1:a523eaac3b7c 9 const unsigned short time_correction = WAIT_TIME * 1000; // correction in msec.
faif 0:5d9b6304f982 10
faif 1:a523eaac3b7c 11 Timer t; // for tracking time
faif 1:a523eaac3b7c 12 unsigned int button_hold_duration; // for tracking how long was the button holded (in msec)
faif 0:5d9b6304f982 13
faif 1:a523eaac3b7c 14 DigitalIn button(p20);
faif 1:a523eaac3b7c 15 DigitalOut myled(LED3);
faif 0:5d9b6304f982 16
faif 1:a523eaac3b7c 17 void flash_led();
faif 1:a523eaac3b7c 18 void debounce();
faif 0:5d9b6304f982 19
faif 0:5d9b6304f982 20 #endif