proyectotecnicas / Mbed 2 deprecated temperaturasconset

Dependencies:   TextLCD mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "AnalogIn.h"
00003 #include "TextLCD.h"
00004 
00005 Serial pc(USBTX, USBRX);
00006 AnalogIn externo(PTC2);
00007 AnalogIn interno(PTB3);
00008 
00009 TextLCD lcd(PTD3, PTA12, PTA4, PTA5, PTC8, PTC9, TextLCD::LCD16x2);
00010 
00011 int temp = 26;
00012 
00013 void recibedato(){
00014     pc.scanf("%d", &temp);
00015     pc.printf("se seteo la temperatura a %.0d\r\n", temp);
00016     }
00017 
00018 int main() {
00019   
00020     pc.baud(115200);
00021     pc.attach(&recibedato);
00022 
00023     float casinterno;
00024     float casexterno;
00025     float tinterno;
00026     float texterno;
00027     int comp;
00028 
00029     while(1){
00030         lcd.cls();
00031         casexterno = externo.read() * 3.3;
00032         texterno = (casexterno + 0.2) * 100 / 5;
00033         
00034         casinterno = interno.read() * 3.3;
00035         tinterno = (casinterno + 2) * 100 / 8;
00036         
00037         lcd.printf("int %.1f set %d",tinterno, temp);
00038         lcd.locate(0,1);
00039         lcd.printf("ext %.1f", texterno);
00040         comp = tinterno;
00041         if(comp == temp)
00042             pc.printf("las temperaturas son iguales\n\r");
00043         else
00044             pc.printf("temperaturas distintas\n\r");
00045         wait(1);
00046     }
00047 }