implement button press/release with double check using fall/rise & timeout

Dependencies:   mbed

Committer:
mintisan
Date:
Sun Aug 28 05:17:30 2016 +0000
Revision:
1:63744318c4d7
Parent:
0:6a3454713c54
Child:
2:d68f26154551
versioin1 : while style

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mintisan 0:6a3454713c54 1 #include "mbed.h"
mintisan 0:6a3454713c54 2
mintisan 1:63744318c4d7 3 DigitalIn mybutton(PB_3);
mintisan 0:6a3454713c54 4 DigitalOut myled(PA_5);
mintisan 0:6a3454713c54 5
mintisan 0:6a3454713c54 6 int main(void)
mintisan 0:6a3454713c54 7 {
mintisan 0:6a3454713c54 8 while(1) {
mintisan 0:6a3454713c54 9 if(mybutton == 0) {
mintisan 0:6a3454713c54 10 myled = 1; // button pressed
mintisan 0:6a3454713c54 11 } else {
mintisan 0:6a3454713c54 12 myled = 0; // button released
mintisan 0:6a3454713c54 13 }
mintisan 0:6a3454713c54 14 }
mintisan 0:6a3454713c54 15 }