while loop light code

Dependencies:   mbed Servo

Revision:
0:8c84f50bc280
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Apr 25 16:11:42 2019 +0000
@@ -0,0 +1,40 @@
+#include "mbed.h"
+#include <stdio.h>
+#include "Servo.h"
+
+AnalogIn ldr(A3); //no filter
+AnalogIn ldrfilter(A6); //filter
+//DigitalOut myLED(LED3);
+//DigitalOut output(D3);
+Servo myservo(D3);
+
+//VALFILTER is the value read in at the filtered photoresistor
+//VAL is the value read in at the regular photoresistor
+
+int main()
+{
+    myservo.write(0);
+   
+    float valfilter,val;
+    int x = 1;
+    
+    while(x!=0){
+    
+        myservo.write(0);
+        valfilter= ldrfilter.read();
+        val= ldr.read();
+        printf("Filter: %f   NoFilter: %f \r\n",valfilter,val);
+       
+        if (valfilter > .83 && valfilter < .85) {
+            if (val > .81 && val <= .84) 
+                myservo.write(1);
+                wait(1);
+                myservo.write(0);
+        }
+        else{
+            myservo.write(0);
+        }
+                
+                
+        }
+    }