Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 1:44689d969206, committed 2020-08-15
- Comitter:
- ellieoin
- Date:
- Sat Aug 15 20:32:17 2020 +0000
- Parent:
- 0:c24760f7606a
- Commit message:
- lad_digital_interrupts complete implemetnation with debouncing
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Aug 15 19:14:44 2020 +0000 +++ b/main.cpp Sat Aug 15 20:32:17 2020 +0000 @@ -11,24 +11,49 @@ InterruptIn btn_center(BTN_CENTER); InterruptIn btn_up(BTN_UP); InterruptIn btn_right(BTN_RIGHT); +Timer timer; +void isr1() { + +} void print_down() { - printf("DOWN\n"); + if (timer.read_ms() > 200) { + printf("DOWN\n"); + timer.reset(); + } } void print_left() { - printf("LEFT\n"); + if (timer.read_ms() > 200) { + printf("LEFT\n"); + timer.reset(); + } } void print_center() { - printf("CENTER\n"); + if (timer.read_ms() > 200) { + printf("CENTER\n"); + timer.reset(); + } } void print_up() { - printf("UP\n"); + if (timer.read_ms() > 200) { + printf("UP\n"); + timer.reset(); + } } void print_right() { - printf("RIGHT\n"); + if (timer.read_ms() > 200) { + printf("RIGHT\n"); + timer.reset(); + } } int main() { + btn_down.mode(PullUp); + btn_left.mode(PullUp); + btn_center.mode(PullUp); + btn_up.mode(PullUp); + btn_right.mode(PullUp); + wait(.001); while (1) { btn_down.rise(callback(&print_down)); btn_left.rise(callback(&print_left)); @@ -36,4 +61,4 @@ btn_up.rise(callback(&print_up)); btn_right.rise(callback(&print_right)); } -} +} \ No newline at end of file