WIP

Dependencies:   mbed

Revision:
0:c146143219c5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Apr 06 17:16:49 2013 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+
+ volatile int rpmcount;
+ unsigned int rpm;
+ unsigned long timeold;
+ 
+ InterruptIn speed(p9);
+ 
+ void setup()
+ {
+    
+    rpmcount = 0;
+    rpm = 0;
+    timeold = 0;
+ }
+ 
+ void loop()
+ {
+   if (rpmcount >= 20) { 
+     //Update RPM every 20 counts, increase this for better RPM resolution,
+     //decrease for faster update
+     rpm = 30*1000/(millis() - timeold)*rpmcount;
+     timeold = millis();
+     rpmcount = 0;
+     Serial.println(rpm,DEC);
+   }
+ }
+ void rpm_fun()
+ {
+   rpmcount++;
+   //Each rotation, this interrupt function is run twice
+ }
\ No newline at end of file