Joseph Forde
/
JF_Interrupt_2
Interrupt_2
Diff: main.cpp
- Revision:
- 2:0330a4b650d1
- Parent:
- 1:61930fcd568c
diff -r 61930fcd568c -r 0330a4b650d1 main.cpp --- a/main.cpp Sat Jun 20 10:38:47 2020 +0000 +++ b/main.cpp Tue Jul 28 11:50:35 2020 +0000 @@ -1,6 +1,7 @@ -#include "mbed.h" +#include "mbed.h" //Preprocessor Directives #include "C12832.h" -C12832 lcd(p5, p7, p6, p8, p11); + +C12832 lcd(p5, p7, p6, p8, p11); // Declarations InterruptIn joystickcenter(p14); InterruptIn button(p9); DigitalOut led(LED1); @@ -8,21 +9,22 @@ int x; void flip() { - { led = !led; // toggles the led when the joystick button is pressed. + { led = !led; // toggles the led when the joystick button is pressed. x=1; } } -int main() { +int main() { //instructions in main () function 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 + button.mode(PullUp); // With this, no external pullup resistor needed + button.rise(&flip); // attach the function address to the rising edge + while(1) { // infinite loop, wait around, interrupts will interrupt this + flash = !flash; // turns LED4 on if off, off if on if (x ==1) { - lcd.printf("test "); + lcd.locate (0,0); + lcd.printf("Variable Is Set"); // Print out to LCD Display x=0; } - wait(0.25); // the instruction to wait for a quarter-second + wait(0.25); // the instruction to wait for a quarter-second } }