Code for Slot Sensor readout. Prints to text file on mbed.

Dependencies:   DebounceIn mbed

Revision:
1:b057042a9427
Parent:
0:6aa040f8bf2c
diff -r 6aa040f8bf2c -r b057042a9427 main.cpp
--- a/main.cpp	Tue Jul 02 22:31:03 2013 +0000
+++ b/main.cpp	Tue Jul 02 22:36:01 2013 +0000
@@ -1,40 +1,35 @@
 #include "mbed.h"
+#include "DebounceIn.h"
 
 Serial pc(USBTX, USBRX); // tx, rx
 
 
-DigitalIn sensor1(p11);
-DigitalIn sensor2(p12);
+DebounceIn sensor1(p11);
+DebounceIn sensor2(p12);
 
 Timer t;
-Timer timer1;
-Timer timer2;
+
 
 
 int main()
 {
     pc.printf("Break sensor to start timer \n \r");
-  
+
     while(1) {
-        if (sensor1) { 
-            timer1.start();
-              if (timer1.read_ms()>500) {
-                t.reset();
-                t.start();
-                pc.printf("Start \n \r");
-                timer1.reset();
-            }
-          
+   
+        if (sensor1) {
+            t.reset();
+            t.start();
+            pc.printf("Start \n \r");
+
+
         } // end sensor 1
-        
+
 
         if (sensor2) {
-            timer1.reset();
-            timer1.start();
-            if (timer1.read_ms()>500) {
-                t.stop();
-                pc.printf("End. Time taken was %f seconds \n \r", t.read());
-            }
+            t.stop();
+            pc.printf("End. Time taken was %f seconds \n \r", t.read());
+
 
         } // end sensor2