Records temperature using TMP36GZ and outputs to HD44780 LCD screen (using tick interrupt routine). Alterable trip level that turns on/off LED with hysteresis. For ST Nucleo F401RE.

Dependencies:   RepeatButton TMP36 GZ TextLCD mbed

Fork of Thermostat_Nucleo by Sapphire

Files at this revision

API Documentation at this revision

Comitter:
MarcoAmerena
Date:
Wed Feb 26 14:20:25 2014 +0000
Parent:
0:f5fbeaf3592c
Commit message:
Thermostat_NucleoF401_v1.00

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Feb 26 13:33:47 2014 +0000
+++ b/main.cpp	Wed Feb 26 14:20:25 2014 +0000
@@ -1,9 +1,40 @@
+/************************************************************************************
+Copyright (c) 2014 Marcus Parker  Sapphire Research and Electronics ltd
+    
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE. 
+
+This program uses the following libraries:  
+mbed by mbed_official                       
+TextLCD by Simon_Ford                       
+TMP36GZ by Tyler_Weaver                     
+RepeatButton by Jeroen_Hilgers              
+                                           
+Wiring instructions:                        
+Two external buttons -> PB_4 and PB_3 
+TMP36GZ pwr->3.3v, Vout->PA_0               
+LCD connections as below                    
+*****************************************************************************************/
+
 #include "mbed.h"
 #include "TextLCD.h"
 #include "TMP36GZ.h"
 #include "RepeatButton.h"
-//#include "InterruptManager.h"
-//#include <cstdlib>
 
 using namespace std;
 #define REPEAT_DELAY 500
@@ -13,7 +44,7 @@
 
 Ticker tick;
 TextLCD lcd(PC_10, PC_12, PA_13, PA_14, PA_15, PB_7); // rs, e, d4-d7
-TMP36GZ temp(PA_0);
+TMP36GZ temp(PA_0); 
 DigitalOut led(LED1);
 
 KeyBuffer TheKeyBuffer(32);
@@ -32,15 +63,15 @@
 
 int main() 
 {
-    level = 21.0;  //Trip level is at %f initially
+    level = 25.0;  //Initial trip level value
     float leveloff;
     int value;
     
-    tick.attach(&disp, 0.5); // setup ticker to call flip after # seconds
+    tick.attach(&disp, 0.5); //Calls display every 0.5 seconds
     
     while(1) 
     { 
-    d = temp.sample();  //Define d and f as temp celsius and fahrenheit
+    d = temp.sample();  //Define d as temp celsius reading
     leveloff = (level - 2);
     
     for(value = TheKeyBuffer.Read(); value != -1; value = TheKeyBuffer.Read()) //Button 1 and Button 3 increase and decrease trip level
@@ -57,14 +88,13 @@
         }
     } 
 
-    if(d >= level)
+    if(d >= level) //Led will light up if temperature is above trip level
     {
     led = 1;
     }
     else if(d <= leveloff)
     {
     led = 0;
-    } 
-    
+    }   
     } 
 }