Night light example program utilizing Grove Seed Light Sensor

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
clively6
Date:
Wed Mar 16 16:28:40 2016 +0000
Commit message:
test;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 176019ee8c91 main.cpp
--- /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
diff -r 000000000000 -r 176019ee8c91 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Mar 16 16:28:40 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/c0f6e94411f5
\ No newline at end of file