MEM / Mbed 2 deprecated ES_2_P5

Dependencies:   mbed

Revision:
0:9661d4f543d7
diff -r 000000000000 -r 9661d4f543d7 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Oct 29 09:51:51 2016 +0000
@@ -0,0 +1,47 @@
+#include "mbed.h"
+#define soglia 1000
+Serial pc(USBTX,USBRX);
+unsigned int RCtime();
+unsigned int photoR;
+DigitalOut out(D6);
+DigitalInOut sens(D4);
+
+int main()
+{
+    pc.printf("ADC data values...\n\r");
+    while (1) {
+        photoR = RCtime();
+        
+        if(photoR == 30000){
+            pc.printf("Nothing connected...\n\r");
+            }
+        else {
+            pc.printf("RC time reading = ");
+            pc.printf("%u\n\r",photoR);
+            
+            if(photoR>soglia){
+                out=1;
+                }
+            else{
+                out=0;
+                 }
+              }
+    wait(0.1);
+                }
+    }
+
+unsigned int RCtime()
+{
+    int reading = 0;
+    sens.output();
+    sens=0;
+    wait_ms(10);
+    sens.input();
+    while(sens == 0){
+        reading++;
+        if(reading == 30000){
+            break;
+            }
+        }
+    return reading;
+    }
\ No newline at end of file