Liam McHale
/
EmbedQ1p2
Diff: main.cpp
- Revision:
- 0:7de212f91ff4
- Child:
- 1:bb422b8b8285
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Aug 08 09:04:49 2020 +0000 @@ -0,0 +1,47 @@ +#include "mbed.h" //preprocessor demands + +Serial pc(USBTX,USBRX);//serial communication to PC via the tx,rx + +InterruptIn down(p12);//global declaration +InterruptIn left(p13);//global declaration +InterruptIn center(p14);//global declaration +InterruptIn up(p15);//global declaration +InterruptIn right(p16);//global declaration + +float debounce(0.5); + + +void Down(){ + pc.printf("DOWN\r\n"); + wait (debounce); + } +void Left(){ + pc.printf("LEFT\r\n"); + wait (debounce); + } +void Center(){ + pc.printf("CENTER\r\n"); + wait (debounce); + } +void Up(){ + pc.printf("UP\r\n"); + wait (debounce); + } +void Right(){ + pc.printf("RIGHT\r\n"); + wait (debounce); + } + +int main(){ + while (1){ + wait(5); + down.rise(&Down); + left.rise(&Left); + center.rise(&Center); + up.rise(&Up); + right.rise(&Right); + down.rise(&Down); + } +} + + \ No newline at end of file