work shop sample

Dependencies:   mbed

Revision:
0:946287229e5e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Oct 24 08:29:30 2012 +0000
@@ -0,0 +1,39 @@
+#include "mbed.h"
+
+DigitalOut myleds[] = {LED1, LED2, LED3, LED4};
+AnalogIn illu(p15);
+
+int main()
+{
+    while(true) {
+        float lx = illu * 3.3 / 3 * 1000;
+        printf("%4.2f\n", lx);
+        
+        if( 250 > lx && lx > 0) {
+            myleds[0] = 1;
+            for(int i = 1; i <4; i++) {
+                myleds[i] = 0;
+            }
+        }else
+
+        if(500 > lx && lx >= 250) {
+            myleds[0] = 1;
+            myleds[1] = 1;
+            myleds[2] = 0;
+            myleds[3] = 0;
+        }else
+
+        if(750 > lx && lx >= 500) {
+            for(int x = 0; x < 3; x++) {
+                myleds[x] = 1;
+            }
+            myleds[3] = 0;
+        }else
+
+        if(lx >= 750) {
+            for(int y = 0; y < 4; y++) {
+                myleds[y] = 1;
+            }
+        }
+    }
+}
\ No newline at end of file