tac

Dependencies:   mbed

Revision:
0:3ba0b3ceda17
diff -r 000000000000 -r 3ba0b3ceda17 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Nov 21 19:02:44 2017 +0000
@@ -0,0 +1,23 @@
+#include "mbed.h"
+
+DigitalOut myled(LED1);
+
+AnalogIn   ain(A0); //initialize input
+Timer t; //initialize timer
+float rpm; //declare rpm variable
+
+int main() {
+    
+    while(1){   //do always
+        if (A0 != 0){  //senses beam crossing
+            while (A0 == 0) { //no longer senses
+            t.start(); //start timer
+                            }
+        t.stop(); //stop timer
+        rpm = t.read()*60;  //obtain value of rpm
+                    }
+            }
+    
+    
+    
+}