Tj Maher
/
lab1digitalinterrupts
Configure the joystick pins as interruptIn and print the directionthe joystick is pushed
Diff: main.cpp
- Revision:
- 0:2f505843d343
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed May 22 11:52:08 2019 +0000 @@ -0,0 +1,43 @@ +#include "mbed.h" + +Serial pc(USBTX,USBRX); +InterruptIn left(p13); +InterruptIn down(p12); +InterruptIn right(p16); +InterruptIn up(p15); +InterruptIn centre(p14); + +void Down() +{ + pc.printf("Down\n"); +} +void Left() +{ + pc.printf("Left\n"); +} +void Centre() +{ + pc.printf("Centre\n"); +} +void Up() +{ + pc.printf("Up\n"); +} +void Right() +{ + pc.printf("Right\n"); +} + +int main() +{ + while(1) { + down.rise(&Down); + left.rise(&Left); + centre.rise(&Centre); + up.rise(&Up); + right.rise(&Right); + down.rise(&Down); + } + + +} \ No newline at end of file