LCD Hello mbed World!

Dependencies:   mbed TextLCD

main.cpp

Committer:
ksestak
Date:
2020-06-19
Revision:
1:b501f964e376
Parent:
0:0a5c73c2369a

File content as of revision 1:b501f964e376:

#include "mbed.h"
#include "TextLCD.h"

TextLCD lcd(p24, p25, p26, p27, p28, p29, p30); // rs, rw, e, d4, d5, d6, d7
AnalogIn Ain(p17);
DigitalOut ledica1(LED1);
float napon;
InterruptIn button(p5);    //define and name the interrupt input
DigitalOut led(LED3);       
DigitalOut flash(LED4);

void led_switch(void);
Ticker time_up;                         //define a Ticker, with name “time_up”
DigitalOut myled(LED2);
void led_switch(){                      //the function that Ticker will call
    myled=!myled;       
}


void ISR1() {            //this is the response to interrupt, i.e. the ISR
  led = !led;
}

int moja_funkcija(float napon){
    if(napon > 2){
        ledica1 = 1;
        }
    else{
        ledica1 = 0;
        }
        return ledica1;
    }

int main() {
    button.rise(&ISR1);
    while(1){
    napon=Ain*3.3; 
    lcd.printf("%4.2f V",napon);
    moja_funkcija(napon);
    wait(0.002);
    lcd.cls();
    flash = !flash;
    wait(0.25);
    time_up.attach(&led_switch, 0.5);             

    }
}

//TextLCD lcd(p24, p25, p26, p27, p28, p29, p30); // rs, rw, e, d4, d5, d6, d7