Measure the width (time-wise) of an incoming pulse.

Dependencies:   dispBoB mbed PCA9635

Revision:
0:dd684fb95312
Child:
1:f04131cae8b8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/counter.cpp	Mon Jul 11 13:41:08 2011 +0000
@@ -0,0 +1,27 @@
+#include "mbed.h"
+#include "dispBoB.h"
+
+dispBoB db(p28, p27, p26);          //instantiate a dispBoB object
+InterruptIn trigger(p12);           //set up the trigger as an external interrupt
+Timer t;
+
+void up(){                       //function to call upon interrupt
+    t.start();
+}
+
+void down(){
+    t.stop();
+    db.locate(0);
+    db.printf("%06d", t.read_ms());     //print counter info to dispBoB 
+    t.reset();
+    t.start();
+}
+
+int main() {
+    trigger.mode(PullUp);           //activate internal pull up (hardware specific)
+    db.init();
+    db.cls();                       //clear screen
+    trigger.rise(&up);           //attach count() to interrupt on rising edge of trigger
+    trigger.fall(&down);
+    db.printf("%06d", t.read_ms()); //display an inital count "000000"
+}