Sarang Kharche
/
digitalInPolling_sample
Solution to Polling Exercise
Fork of digitalInPolling_sample by
Revision 3:914be74674bb, committed 2018-02-01
- Comitter:
- Sarang
- Date:
- Thu Feb 01 17:19:35 2018 +0000
- Parent:
- 2:cd1fe8c29793
- Commit message:
- Final;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r cd1fe8c29793 -r 914be74674bb main.cpp --- a/main.cpp Tue Jan 16 18:02:44 2018 +0000 +++ b/main.cpp Thu Feb 01 17:19:35 2018 +0000 @@ -14,6 +14,8 @@ Thread pollT ; // thread to poll volatile int pressEvent = 0 ; // Variabe set by the polling thread +volatile int timez = 200 ; + enum buttonPos { up, down, bounce }; // Button positions void polling() { buttonPos pos = up ; @@ -54,10 +56,23 @@ pollT.start(callback(polling)); while(true) { + led = !led ; if (pressEvent) { pressEvent = 0 ; // clear the event variable - led = !led ; + + if (timez<1000) + { + timez+=200; + } + + else + { + timez=200; + } } - Thread::wait(100) ; + + Thread::wait(timez); + } -} \ No newline at end of file +} +