sapik samat / Mbed 2 deprecated HeaterControl

Dependencies:   C12832_lcd LM75B mbed

Fork of HeaterControl by Rostam Siamak

Files at this revision

API Documentation at this revision

Comitter:
sapik
Date:
Wed Aug 22 23:36:42 2018 +0000
Parent:
1:4a768c18e543
Commit message:
Intelligent heater control

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 4a768c18e543 -r 8d3811748026 main.cpp
--- a/main.cpp	Sun Dec 29 16:58:06 2013 +0000
+++ b/main.cpp	Wed Aug 22 23:36:42 2018 +0000
@@ -1,52 +1,53 @@
-//heater control using LM75B Temp sensor and Pot1 as inputs and LED1 and 2 as too hot and too cold tempreture indicators. 
-//LED 4 is used to indicate heater on/off
+//heater_cutoff control using LM75B Temp sensor and Pot1 as inputs and LED1 and 2 as too hot and too cold tempreture indicators. 
+//LED 3 is used to indicate heater_cutoff_cutoff on/off
 
 #include "mbed.h"
 #include "C12832_lcd.h"
 #include "LM75B.h"
 
-DigitalOut toohot(LED1);
-DigitalOut toocold(LED2);
-DigitalOut heater(LED4);
+DigitalOut toast_ready(LED1);
+DigitalOut toast_hold(LED2);
+DigitalOut heater_cutoff(LED3);
 
 C12832_LCD disp;
 LM75B temp(p28,p27);
 AnalogIn therm(p19);
 
-float room_temp;
-float therm_set;
+float toast_temp;
+float max_set;
 
 int main()
 {
-    toocold=0;
-    toohot=0;
+    toast_hold=0;
+    toast_ready=0;
     
     while(1) 
     {
 
-    therm_set=therm.read() *45.0f;// Reading and caliberating the thermostat setting 
-    room_temp=temp.read();
+    max_set=therm.read() *150.0f;// Reading and caliberating the thermostat setting 
+    toast_temp=temp.read();
     disp.cls(); // clear the screen
     disp.locate(0,0);
-    disp.printf("Thermostat setting: %.2fc", therm_set);
+    disp.printf("Max Temperature: %.2fc", max_set);
     disp.locate(0,10);
-    disp.printf("Room Temperature: %.2fc", room_temp);
+    disp.printf("toaster Temperature: %.2fc", toast_temp);
     
-    if (room_temp>24.0f)
+    if (toast_temp>24.0f)
     {   
-        toocold=0;
-        toohot=1;
+        toast_hold=0;
+        toast_ready=1;
     }
     else 
     {
-        toocold=1;
-        toohot=0;
+        toast_hold=1;
+        toast_ready=0;
     }
     
-    if(room_temp<therm_set)
-        heater=1;
+    if(toast_temp>max_set)
+        heater_cutoff=1;
     else
-        heater=0;
+        heater_cutoff=0;
+
     
      wait(0.1);  
     }