Ger Roche
/
interupt2
report
Revision 0:7ea89477d20f, committed 2019-05-24
- Comitter:
- GerRoche
- Date:
- Fri May 24 14:44:57 2019 +0000
- Commit message:
- lab 2
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 7ea89477d20f main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri May 24 14:44:57 2019 +0000 @@ -0,0 +1,18 @@ +#include "mbed.h" + +InterruptIn button(p5); +DigitalOut led(LED1); +DigitalOut flash(LED4); + +void flip() { + led = !led; // toggles the led, when pressing a button connects ground to p5. + } + + int main() { + button.mode(PullUp); // with this command, no external pullup resistor needed + button.rise(&flip); // attach the function address to the rising edge (of p5) + while(1) { // wait around, interrupts will interrupt this! + flash = !flash; // this just turns LED4 on and off every quarter-second + wait(0.25); // this is the instruction to wait for a quarter-second + } +}
diff -r 000000000000 -r 7ea89477d20f mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri May 24 14:44:57 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file