Interrupt_1

Dependencies:   mbed C12832

Committer:
jforde
Date:
Tue Jul 28 11:49:40 2020 +0000
Revision:
0:24496aa93ddf
Interrupt_1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jforde 0:24496aa93ddf 1 #include "mbed.h" //Preprocessor Directives
jforde 0:24496aa93ddf 2 #include "C12832.h"
jforde 0:24496aa93ddf 3
jforde 0:24496aa93ddf 4 C12832 lcd(p5, p7, p6, p8, p11); // Declarations
jforde 0:24496aa93ddf 5 InterruptIn joystickcenter(p14);
jforde 0:24496aa93ddf 6 InterruptIn button(p9);
jforde 0:24496aa93ddf 7 DigitalOut led(LED1);
jforde 0:24496aa93ddf 8 DigitalOut flash(LED4);
jforde 0:24496aa93ddf 9 int x;
jforde 0:24496aa93ddf 10
jforde 0:24496aa93ddf 11
jforde 0:24496aa93ddf 12 void flip(int X=1) {
jforde 0:24496aa93ddf 13 led = !led; // toggles the led when the joystick button is pressed.
jforde 0:24496aa93ddf 14 }
jforde 0:24496aa93ddf 15
jforde 0:24496aa93ddf 16 int main() { //instructions in main () function
jforde 0:24496aa93ddf 17 joystickcenter.rise(&flip); // attach the function address to the rising edge
jforde 0:24496aa93ddf 18 button.mode(PullUp); // With this, no external pullup resistor needed
jforde 0:24496aa93ddf 19 button.rise(&flip); // attach the function address to the rising edge
jforde 0:24496aa93ddf 20 while(1) { // infinite loop, wait around, interrupts will interrupt this
jforde 0:24496aa93ddf 21 if(x==1);{
jforde 0:24496aa93ddf 22 lcd.locate(0.0);
jforde 0:24496aa93ddf 23 lcd.printf("Variable Is Set"); // Print out to LCD Display
jforde 0:24496aa93ddf 24 flash = !flash; // turns LED4 on if off, off if on
jforde 0:24496aa93ddf 25 wait(0.25); // the instruction to wait for a quarter-second
jforde 0:24496aa93ddf 26 }
jforde 0:24496aa93ddf 27 }
jforde 0:24496aa93ddf 28 }