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.
main.cpp
- Committer:
- ellieoin
- Date:
- 2020-08-15
- Revision:
- 1:44689d969206
- Parent:
- 0:c24760f7606a
File content as of revision 1:44689d969206:
#include "mbed.h" #define BTN_DOWN p12 #define BTN_LEFT p13 #define BTN_CENTER p14 #define BTN_UP p15 #define BTN_RIGHT p16 InterruptIn btn_down(BTN_DOWN); InterruptIn btn_left(BTN_LEFT); InterruptIn btn_center(BTN_CENTER); InterruptIn btn_up(BTN_UP); InterruptIn btn_right(BTN_RIGHT); Timer timer; void isr1() { } void print_down() { if (timer.read_ms() > 200) { printf("DOWN\n"); timer.reset(); } } void print_left() { if (timer.read_ms() > 200) { printf("LEFT\n"); timer.reset(); } } void print_center() { if (timer.read_ms() > 200) { printf("CENTER\n"); timer.reset(); } } void print_up() { if (timer.read_ms() > 200) { printf("UP\n"); timer.reset(); } } void print_right() { 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)); btn_center.rise(callback(&print_center)); btn_up.rise(callback(&print_up)); btn_right.rise(callback(&print_right)); } }