Konstrukcijski zadatak V0

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 "thermistor.h"
00003 #include "TextLCD.h"
00004 
00005 TextLCD lcd(p19, p20, p21, p22, p23, p24);
00006 Temperature  senzor1 (p17);
00007 InterruptIn button(p26);
00008 float temp, mini, maxi;
00009 Ticker tik1;
00010 DigitalOut ledica (LED2);
00011 
00012 
00013 void reset() {
00014 mini=temp;
00015 maxi=temp;
00016 }
00017 
00018  void ispis(float temp, float min, float max) {
00019      lcd.locate(0,0);
00020      lcd.printf("temp=%.1f",temp);
00021      lcd.locate(0,1);
00022      lcd.printf("MIN=%.0f",mini);
00023      lcd.locate(8,1);
00024      lcd.printf("MAX=%.0f",maxi);
00025      
00026  }
00027 
00028 void tiker1(){
00029     ledica=!ledica;
00030     lcd.cls();
00031     ispis(temp, mini, maxi);
00032     }
00033     
00034 int main() {
00035     temp=senzor1.get_temperature();
00036     mini=temp;
00037     maxi=temp;
00038     tik1.attach(&tiker1, 0.15);
00039     while(1) {
00040         button.fall(&reset);
00041         temp=senzor1.get_temperature();
00042         if(temp<mini)
00043             mini=temp;
00044         if(temp>maxi)
00045             maxi=temp;
00046         
00047     }
00048 }