darkness activated switch

Dependencies:   mbed

Revision:
1:8cf180275a19
Parent:
0:aa10f42a839d
--- a/main.cpp	Sat Feb 11 14:13:27 2012 +0000
+++ b/main.cpp	Sun Mar 15 17:16:15 2015 +0000
@@ -1,22 +1,19 @@
 #include "mbed.h"
 #include "main.h"
 
-static const float threshOff = 0.5;      // when to turn the led on
-static const float threshOn = 0.4;     // when to turn the led off
-
 int main () 
 {
-    float ldr_value;
+    float ldr_value = 0;
     while (true) 
     {
         ldr_value = myldr;
-        if (ldr_value > threshOff)
+        if (ldr_value > THRES_OFF)
+        {
+            myled = LedOn;
+        }
+        if (ldr_value < THRES_ON)
         {
             myled = LedOff;
         }
-        if (ldr_value < threshOn)
-        {
-            myled = LedOn;
-        }
     }
 }