
LAB#1: InterruptIn
Diff: Emb_LAB1.cpp
- Revision:
- 1:cd0e7975714c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Emb_LAB1.cpp Thu Aug 15 16:56:39 2019 +0000 @@ -0,0 +1,46 @@ +// IT Tralee Mechatronics: Embedded Systems LAB#1 + + +#include "mbed.h" + +InterruptIn d(p12); // down +InterruptIn l(p13); // left +InterruptIn c(p14); // centre +InterruptIn u(p15); // up +InterruptIn r(p16); // right + + +DigitalOut flash(LED1); + +void left() { + printf("Left \n \r"); // print +} + +void right() { + printf("Right \n \r"); +} + +void up() { + printf("Up \n \r"); +} + +void down() { + printf("Down \n \r"); +} + +void centre() { + printf("Centre \n \r"); +} + +int main() { + l.rise(&left); // address to interrupt rising edge + r.rise(&right); + u.rise(&up); + d.rise(&down); + c.rise(¢re); + + while(1) { // LED flash = interrupt active + flash = !flash; + wait(0.2); + } +}