control de temperatura por medio de un sensor LM35

Dependencies:   Keypad TextLCD mbed

Fork of control_onoff by Frank Girald

Files at this revision

API Documentation at this revision

Comitter:
Luis_San
Date:
Thu Nov 16 01:03:09 2017 +0000
Parent:
0:e007beba2811
Commit message:
Control ON / OFF de un bombillo de 60W basado en temperaturas dadas por un LM35

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed May 03 16:09:35 2017 +0000
+++ b/main.cpp	Thu Nov 16 01:03:09 2017 +0000
@@ -7,7 +7,7 @@
 DigitalOut pinOut(PTB1);
 
 TextLCD lcd(PTE20,PTE21,PTE22,PTE23,PTE29,PTE30, TextLCD::LCD16x2); // Rs, E, d4, d5, d6, d7, RW=GND
-Keypad keypad(PTC4,PTC3,PTC0,PTC7,PTC11,PTC10,PTC6,PTC5); // c1, c2, c3, c4, f1, f2, f3, f4
+Keypad keypad(PTB11,PTB10,PTB9,PTB8,PTE5,PTE4,PTE3,PTE2); // c1, c2, c3, c4, f1, f2, f3, f4
 
 char key;
 int released=1,unidades,decenas,centenas;
@@ -29,10 +29,12 @@
       lcd.cls();
       lcd.locate(1,1);
       lcd.printf("SETUP...");
+      rs232.printf("SETUP...");
       wait(1);
       lcd.cls();
       while(i<=2){
       read_kpad();
+      wait(0.5);
       if(key!='\0'){ 
          if(i==0){centenas=key-48;lcd.locate(1,1);lcd.printf("%c",key);if(centenas>1){centenas=1;}}
          if(i==1){decenas=key-48;lcd.locate(2,1);lcd.printf("%c",key);}
@@ -44,31 +46,30 @@
          lcd.cls();
          lcd.locate(1,1);
          lcd.printf("SP: %fdegC    ",setpoint);
+         rs232.printf("SP: %fdegC    ",setpoint);
          wait(1);
          lcd.cls();
          lcd.locate(1,1);
          lcd.printf("SETUP OK");
+         rs232.printf("SETUP OK");
          wait(1);
 }
 
-
-
-
 int main()
 {
-
+    rs232.baud(115200);
     rs232.printf("Control ON-OFF \n\r");
     lcd.printf("Control ON-OFF \r\n");
     wait(1);
     lcd.cls();
 
     while (1) {
-        valor_adc=AnalogPin.read()*5;
+        valor_adc=AnalogPin.read()*300;//guardar en entero y mostrar el enetero
         lcd.locate(1,1);
         lcd.printf("SP; %fdegC ",setpoint);
         lcd.locate(1,2);
         lcd.printf("PV; %fdegC ",valor_adc);
-        rs232.printf("%f,%f",setpoint,valor_adc);
+        rs232.printf("%f,%f \r \n",setpoint,valor_adc);
         
         read_kpad();
         if(key=='*') {
@@ -80,7 +81,7 @@
         } else {
             pinOut=1;;
         }
-
+        wait(0.3);
 
     }
 }
\ No newline at end of file