Dependencies:   mbed C12832_lcd

main.cpp

Committer:
brendanmleech
Date:
2020-07-30
Revision:
0:ae4dd2da243d

File content as of revision 0:ae4dd2da243d:


#include "mbed.h"
#include "C12832_lcd.h"

AnalogIn ain(p19);       // ain is an object of class Analogin
DigitalOut led(LED1);    // led is an object if class Digitalout
C12832_LCD lcd;          // LCD is an object of class C12832
float temperature;
InterruptIn joystickcenter(p14);
InterruptIn button(p9);
Timer debounce;
int i;
int x;

void flip()  {
led = !led; // toggles the led when the joystick button is pressed.
if (debounce.read_ms() > 1000 )
x = 1;
debounce.reset();
}

int main() {
temperature = ain*600-200;
        lcd.locate(0,0);
        lcd.printf("Temperature needs reset");

        if(temperature > 295) {
            for (i=0;i<60;i++);
            led=1;
            wait(0.5);
        x=1;
        {
        wait(0.5);                   //  wait for a half a second

    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!
        if(x==1){  // set x to 1 in flip() and compare it to 1 (i.e. if x ==1 { ... } )
        
        
   }
   } 
}
}
}