Lauren Taylor / Mbed 2 deprecated phototransistor

Dependencies:   mbed

Revision:
1:279fcab0c394
Parent:
0:46b2c955924b
Child:
2:c76b070c2a55
--- a/main.cpp	Thu Mar 08 18:17:55 2018 +0000
+++ b/main.cpp	Thu Mar 08 18:20:06 2018 +0000
@@ -1,16 +1,26 @@
 #include "mbed.h" 
 AnalogIn lightSensor(p20); 
+DigitalOut ledRed(p25);
+
 Serial pc(USBTX,USBRX); 
 int main() { 
     float x; 
     int n = 10; 
-    while(1) { 
+    while(1) {
+        ledRed = 1; 
         // Average n readings of the light sensor 
         x = 0; 
         for (int i = 0; i<n; i++) 
             x = x + lightSensor; 
         x = x/n;
-        pc.printf("%.4f\r\n", x); 
+        pc.printf("%.4f\r\n", x);
+        ledRed = 0; 
+        // Average n readings of the light sensor 
+        x = 0; 
+        for (int i = 0; i<n; i++) 
+            x = x + lightSensor; 
+        x = x/n;
+        pc.printf("%.4f\r\n", x);
         wait(0.2); 
     } 
 } 
\ No newline at end of file