Night light example program utilizing Grove Seed Light Sensor

Dependencies:   mbed

Revision:
0:176019ee8c91
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Mar 16 16:28:40 2016 +0000
@@ -0,0 +1,28 @@
+/*Graduated Night light with Seed Grove Ambient Light sensor
+Casey Lively
+March 2016*/
+
+//Read in ambient light sensor with mbed LPC1768
+#include "mbed.h"
+
+AnalogIn sensor(p20);//
+BusOut lights(LED1, LED2, LED3, LED4);
+
+int main() {
+    float val;
+    float threshold = .03; //User specified for night-light mode. Set to .03 for light measurement mode
+    while(1) {
+        val = sensor.read();
+        
+        //Uncomment the line below for debugging.
+       // printf("Sensor reading: %2.2f - %2.2f\r\n", val, (float)(1023-val)*10/val); //print through debug serial connection
+        
+        if(val <= threshold)
+            lights = 15; //set all bus lines to 1
+        else
+            lights = 0; //set all bus lines to 0
+        
+       
+        wait(0.1);
+    }//end while(1)
+}//end Main
\ No newline at end of file