Dependencies:   mbed C12832 LM75B

Revision:
7:809bcb2e543c
Parent:
6:5bed20b6274d
Child:
8:82af3c3b631e
--- a/main.cpp	Wed Apr 28 13:09:27 2021 +0000
+++ b/main.cpp	Thu May 20 07:59:37 2021 +0000
@@ -4,8 +4,9 @@
 
 LM75B tempsensor(p28,p27);           // temp sensor initialised, pins 28 & 27
 Serial pc(USBTX,USBRX);              // Transmit & Receive initialised
+C12832 lcd(p5, p7, p6, p8, p11);     // LCD Pins initialised
 DigitalOut testled(LED1);            // LED 1 digital out initialised
-C12832 lcd(p5, p7, p6, p8, p11);     // LCD Pins initialised
+AnalogIn Heater (p19);               //Read digital in
 DigitalOut RED(p23);                 // colour LED 1
 DigitalOut GREEN(p24);               // colour LED 2
 DigitalOut BLUE(p25);                // colour LED 3
@@ -22,19 +23,27 @@
             pc.printf("Error. Tempsensor not connected \n");
         }
 
-        if (tempsensor > 25.000) {      //if tempsensor is more than 25, red led
+        if (tempsensor > 25.000 && Heater > 0.5) {      //if tempsensor is more than 25, display red led
             RED = 0;
             GREEN = 1;
             BLUE = 1;
-        } else    {                     //else display blue led led
+            lcd.printf(" switch OFF Heat ");
+            wait (.5);
+        }                                      //Delay for clarity
+
+        if (tempsensor < 25.000 && Heater < 0.5) {      //if tempsensor is more than 25, display red led
             RED = 1;
             GREEN = 1;
             BLUE = 0;
+            lcd.printf(" switch OFF Heat ");
+            wait (.5);                                        //Delay for clarity
         }
 
         lcd.cls();                                          //Clear LCD screen
         lcd.locate(0,0);                                    // LCD text location
         lcd.printf("Temp = %.3f\n", (float)tempsensor);     // Print "Temp = " tempsensor value
-        wait(1.0);                                          //Delay for clarity
     }
-}
\ No newline at end of file
+
+
+}
+