Volkan Esendag / Mbed 2 deprecated mbed_PortableWeatherStation

Dependencies:   BMP180 N5110 PowerControl mbed

Revision:
9:693f69e0a175
Parent:
8:29ac7d274ae0
Child:
10:06b35733ca25
--- a/main.cpp	Sun Apr 19 20:02:08 2015 +0000
+++ b/main.cpp	Sun Apr 19 20:55:49 2015 +0000
@@ -546,7 +546,18 @@
                 printReadings();
                 lcd.refresh();
                 
-            }
+                if(temp > tempThres[tempSetting].thresTemp){ //if temperature exceeds set threshold
+                    redLED = 0.95;   //apply a PWM signal and light up the red LED
+                    buzzerPwm = 0.5;   //apply a PWM signal to buzzer with 50% duty ratio to imitate a square wave.
+                    buzzerPwm.period_us(500);  //period of 500 us or 0.5 ms equals a frequency of 2000 Hz.
+                    greenLED = 0.0; //if green LED has been set, reset it.
+                }    
+                else{  //if not, light up green LED to signify that the device is operating normally.
+                    greenLED = 1.0;
+                    buzzerPwm = 0.0; //if PWM signal is set and threshold exceeded once, stop the buzzer until threshold is reached again.
+                    redLED = 0.0; //if red LED has been lit up previously, turn it off.
+                }
+            } //terminate dispTimerFlag        
             
             if(menuButtonFlag == 1){  //if menu button has been pressed once