CA 2.3 Modified Code

Dependencies:   mbed C12832

Committer:
vmg
Date:
Sun Jul 26 20:55:57 2020 +0000
Revision:
0:2679ca1e9214
CA 2.3 Modified Code

Who changed what in which revision?

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