David Mc Sherry
/
INS_LAB_Q3
Revision 0:61ea4e44e701, committed 2021-08-18
- Comitter:
- t00214916
- Date:
- Wed Aug 18 15:34:24 2021 +0000
- Commit message:
- Interrupt experiment
Changed in this revision
diff -r 000000000000 -r 61ea4e44e701 C12832.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/C12832.lib Wed Aug 18 15:34:24 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/chris/code/C12832/#7de323fa46fe
diff -r 000000000000 -r 61ea4e44e701 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Aug 18 15:34:24 2021 +0000 @@ -0,0 +1,36 @@ +#include "mbed.h" +#include "C12832.h" // including lcd library + +InterruptIn joystickcenter(p14); +InterruptIn button(p9); +DigitalOut led(LED1); +DigitalOut flash(LED4); +C12832 lcd(p5, p7, p6, p8, p11); + +int var; // declare a variable + +void flip() // Classes a flip function +{ + var = 1; // Variable is high + led = !led; // toggles the led when the joystick button is pressed. +} +int main() +{ + joystickcenter.rise(&flip); //attach the function address to the rising edge + button.mode(PullUp); // With this, no external pullup resistor needed + button.rise(&flip); // attach the function address to the rising edge + while(1) { // wait around, interrupts will interrupt this! + flash = !flash; // turns LED4 on if off, off if on + wait(0.25); // the instruction to wait for a quarter-second + + + if (var == 1) // Check if variable has been set + { + lcd.locate(0,0); // print to LCD + lcd.printf("The variable has been set"); + wait(3); + lcd.cls(); // Clears LCD + var=0; // Variable returns to low state + } + } +} \ No newline at end of file
diff -r 000000000000 -r 61ea4e44e701 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Aug 18 15:34:24 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file