Peiling Yi
/
digitalInPolling_modify2
lab2-part1
Fork of digitalInPolling_sample by
Diff: main.cpp
- Revision:
- 1:4709af498799
- Parent:
- 0:a66a8cb0012c
- Child:
- 2:cd1fe8c29793
diff -r a66a8cb0012c -r 4709af498799 main.cpp --- a/main.cpp Mon Jan 23 13:53:49 2017 +0000 +++ b/main.cpp Tue Jan 24 18:24:25 2017 +0000 @@ -23,19 +23,19 @@ while (true) { switch (pos) { case up : - if (button == 1) { // now down + if (button == 0) { // now down pressEvent = 1 ; // transition occurred pos = down ; } break ; case down : - if (button == 0) { // no longer down + if (button == 1) { // no longer down bcounter = 3 ; // wait four cycles pos = bounce ; } break ; case bounce : - if (button == 1) { // down again - button has bounced + if (button == 0) { // down again - button has bounced pos = down ; // no event } else if (bcounter == 0) { pos = up ; // delay passed - reset to up