UH IoT / Mbed 2 deprecated IoT Project Final

Dependencies:   C12832 LM75B PWM_Tone_Library mbed Grove_Air_Quality_Sensor_Library

Revision:
4:4a1b31edb7b1
Parent:
3:9c4e6163a71b
Child:
5:4d8495cf1c10
--- a/main.cpp	Wed Feb 22 11:32:35 2017 +0000
+++ b/main.cpp	Thu Feb 23 12:46:56 2017 +0000
@@ -1,13 +1,18 @@
 #include "mbed.h"
+#include "pwm_tone.h"
 #include "C12832.h"
-#include "pwm_tone.h"
+
 
 //DigitalOut myled(LED1);
 PwmOut Buzzer(D5);
-C12832 lcd(p5, p7, p6, p8, p11);
-AnalogIn sensor(p16);
+C12832 lcd (p5, p7, p6, p8, p11);
+AnalogIn sensor(p17);
 PwmOut spkr(p26);
 BusOut RGB (p23, p24, p25);
+BusIn Up(p15);
+BusIn Down(p12);
+BusIn Left(p13);
+BusIn Right(p16);
 
 float C_3 = 1000000/Do3,
        Cs_3 = 1000000/Do3s,
@@ -56,10 +61,11 @@
 int count;                // for computing average reading
 float total;
 float average;
-int MAX = 22;
-int MIN = 20;
-int Boiler_MAX = MIN + 2;
+float max = 22;
+float min = 20;
+int Boiler_max = min + 2;
 
+void initialize();
 
 void buzz()
 {
@@ -71,11 +77,16 @@
         spkr=0.0;
 }
 
-int main() {
+int main() 
+{
+    initialize(); 
     count = 0;
     total = 0.0;
-//    RGB = 0xFF;
-//    buzz();
+    RGB = 0xFF;
+    buzz();
+    
+    
+    
     
     while (1) {
         // formula is analog reading * multiplier
@@ -84,8 +95,33 @@
         count++;
         total += temp;
         average = total / count;
+        // min = min * 1;
         
-        if(temp > MAX)
+           if (Up) 
+        {
+            
+            min++;
+        }
+            
+        if (Down)
+        {
+            
+            min--;        
+        }     
+           if (Left) 
+        {
+            
+            max--;
+        }
+            
+        if (Right)
+        {
+            
+            max++;        
+        }   
+              
+                
+        if(temp > max)
         {
             RGB = 0xff;
             buzz();
@@ -95,7 +131,7 @@
             RGB = 0x19;
         }
         
-        if(temp < MIN)
+        if(temp < min)
         {
             RGB = 0x06;
         }
@@ -105,31 +141,18 @@
         }
         
         lcd.cls();
-        lcd.locate(0,3);
-        lcd.printf("Temperature= %6.2f \n Average= %5.1f \n", temp  , average );
-        wait(1);
-    }
+        lcd.locate(0,0);
+        lcd.printf("Temp= %6.2f  Avg= %5.1f ", temp  , average );
+        lcd.locate(0,12);
+        lcd.printf("min= %6.0f max= %6.0f", min, max);
+        
+        wait(0.5); 
+        }
+
 }
 
-//int main(void)
-//{
-//    Tune(Buzzer, C_4, 4);  //4 Octave C beat 4/16
-//    wait_ms(250);
-//    Tune(Buzzer, D_4, 4);  //4 Octave D beat 4/16
-//    wait_ms(250);
-//    Tune(Buzzer, E_4, 4);  //4 Octave E beat 4/16
-//    wait_ms(250);
-//
-//    int i;
-//
-//    for(i=0; i<tones_num; i++) {
-//        Auto_tunes(Buzzer, tones[i], 4); // Auto performance
-//        Stop_tunes(Buzzer);
-//    }
-//
-//}
-
-
-
-
-
+void initialize()
+{
+    lcd.cls();
+    lcd.locate(0,0);
+}