lee las 2 temperaturas y de la terminal la deseada imprime en el lcd lsa 2 temperetaturas, la deseada y en la terminal imprime si la interna es igual o distinta a la deseada

Dependencies:   TextLCD mbed

Committer:
josedaparte
Date:
Sat Nov 28 12:20:53 2015 +0000
Revision:
0:05e7963d2ae2
culiau

Who changed what in which revision?

UserRevisionLine numberNew contents of line
josedaparte 0:05e7963d2ae2 1 #include "mbed.h"
josedaparte 0:05e7963d2ae2 2 #include "AnalogIn.h"
josedaparte 0:05e7963d2ae2 3 #include "TextLCD.h"
josedaparte 0:05e7963d2ae2 4
josedaparte 0:05e7963d2ae2 5 Serial pc(USBTX, USBRX);
josedaparte 0:05e7963d2ae2 6 AnalogIn externo(PTC2);
josedaparte 0:05e7963d2ae2 7 AnalogIn interno(PTB3);
josedaparte 0:05e7963d2ae2 8
josedaparte 0:05e7963d2ae2 9 TextLCD lcd(PTD3, PTA12, PTA4, PTA5, PTC8, PTC9, TextLCD::LCD16x2);
josedaparte 0:05e7963d2ae2 10
josedaparte 0:05e7963d2ae2 11 int temp = 26;
josedaparte 0:05e7963d2ae2 12
josedaparte 0:05e7963d2ae2 13 void recibedato(){
josedaparte 0:05e7963d2ae2 14 pc.scanf("%d", &temp);
josedaparte 0:05e7963d2ae2 15 pc.printf("se seteo la temperatura a %.0d\r\n", temp);
josedaparte 0:05e7963d2ae2 16 }
josedaparte 0:05e7963d2ae2 17
josedaparte 0:05e7963d2ae2 18 int main() {
josedaparte 0:05e7963d2ae2 19
josedaparte 0:05e7963d2ae2 20 pc.baud(115200);
josedaparte 0:05e7963d2ae2 21 pc.attach(&recibedato);
josedaparte 0:05e7963d2ae2 22
josedaparte 0:05e7963d2ae2 23 float casinterno;
josedaparte 0:05e7963d2ae2 24 float casexterno;
josedaparte 0:05e7963d2ae2 25 float tinterno;
josedaparte 0:05e7963d2ae2 26 float texterno;
josedaparte 0:05e7963d2ae2 27 int comp;
josedaparte 0:05e7963d2ae2 28
josedaparte 0:05e7963d2ae2 29 while(1){
josedaparte 0:05e7963d2ae2 30 lcd.cls();
josedaparte 0:05e7963d2ae2 31 casexterno = externo.read() * 3.3;
josedaparte 0:05e7963d2ae2 32 texterno = (casexterno + 0.2) * 100 / 5;
josedaparte 0:05e7963d2ae2 33
josedaparte 0:05e7963d2ae2 34 casinterno = interno.read() * 3.3;
josedaparte 0:05e7963d2ae2 35 tinterno = (casinterno + 2) * 100 / 8;
josedaparte 0:05e7963d2ae2 36
josedaparte 0:05e7963d2ae2 37 lcd.printf("int %.1f set %d",tinterno, temp);
josedaparte 0:05e7963d2ae2 38 lcd.locate(0,1);
josedaparte 0:05e7963d2ae2 39 lcd.printf("ext %.1f", texterno);
josedaparte 0:05e7963d2ae2 40 comp = tinterno;
josedaparte 0:05e7963d2ae2 41 if(comp == temp)
josedaparte 0:05e7963d2ae2 42 pc.printf("las temperaturas son iguales\n\r");
josedaparte 0:05e7963d2ae2 43 else
josedaparte 0:05e7963d2ae2 44 pc.printf("temperaturas distintas\n\r");
josedaparte 0:05e7963d2ae2 45 wait(1);
josedaparte 0:05e7963d2ae2 46 }
josedaparte 0:05e7963d2ae2 47 }