darkness activated switch

Dependencies:   mbed

Revision:
0:aa10f42a839d
Child:
1:8cf180275a19
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Feb 11 14:13:27 2012 +0000
@@ -0,0 +1,22 @@
+#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;
+    while (true) 
+    {
+        ldr_value = myldr;
+        if (ldr_value > threshOff)
+        {
+            myled = LedOff;
+        }
+        if (ldr_value < threshOn)
+        {
+            myled = LedOn;
+        }
+    }
+}