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

Dependencies:   dispBoB mbed PCA9635

Revision:
2:bb7e46464d17
Parent:
1:f04131cae8b8
--- a/counter.cpp	Mon Jul 11 13:57:07 2011 +0000
+++ b/counter.cpp	Tue Jul 12 10:05:44 2011 +0000
@@ -12,15 +12,19 @@
 void down(){                        //call this upon falling edge
     t.stop();                       //stop timer
     db.locate(0);
-    db.printf("%06d", t.read_ms());     //print counter info to dispBoB 
+    db.printf("%06d", t.read_ms()); //print counter info to dispBoB 
     t.reset();                      //reset timer
 }
 
 int main() {
     trigger.mode(PullUp);           //activate internal pull up (hardware specific)
-    db.init();                      //again ALWAYS initialise dispBoB
-    db.cls();                       //clear screen
+    db.init();                      //ALWAYS initialise dispBoB
+    db.cls();                      
     trigger.rise(&up);              //attach up() to interrupt on rising edge of trigger
     trigger.fall(&down);            //attach down() to interrupt on falling edge of trigger
-    db.printf("%06d", t.read_ms()); //display an inital count "000000"
+    db.printf("%06d", t.read_ms()); //display an initial count "000000"
+    
+    //To change the timebase just replace the read_ms() function with
+    //read() for seconds and read_us() for microseconds. These use a 32bit 
+    //int microsecond counter, so have a max time of ~30mins
 }