Karlo Šestak / Mbed 2 deprecated regulator_napona

Dependencies:   mbed TextLCD

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "TextLCD.h"
00003 
00004 TextLCD lcd(p24, p25, p26, p27, p28, p29, p30); // rs, rw, e, d4, d5, d6, d7
00005 AnalogIn Ain(p17);
00006 DigitalOut ledica1(LED1);
00007 float napon;
00008 InterruptIn button(p5);    //define and name the interrupt input
00009 DigitalOut led(LED3);       
00010 DigitalOut flash(LED4);
00011 
00012 void led_switch(void);
00013 Ticker time_up;                         //define a Ticker, with name “time_up”
00014 DigitalOut myled(LED2);
00015 void led_switch(){                      //the function that Ticker will call
00016     myled=!myled;       
00017 }
00018 
00019 
00020 void ISR1() {            //this is the response to interrupt, i.e. the ISR
00021   led = !led;
00022 }
00023 
00024 int moja_funkcija(float napon){
00025     if(napon > 2){
00026         ledica1 = 1;
00027         }
00028     else{
00029         ledica1 = 0;
00030         }
00031         return ledica1;
00032     }
00033 
00034 int main() {
00035     button.rise(&ISR1);
00036     while(1){
00037     napon=Ain*3.3; 
00038     lcd.printf("%4.2f V",napon);
00039     moja_funkcija(napon);
00040     wait(0.002);
00041     lcd.cls();
00042     flash = !flash;
00043     wait(0.25);
00044     time_up.attach(&led_switch, 0.5);             
00045 
00046     }
00047 }
00048 
00049 //TextLCD lcd(p24, p25, p26, p27, p28, p29, p30); // rs, rw, e, d4, d5, d6, d7
00050