Measure the time interval between two consecutive rising edges
Dependencies: dispBoB mbed PCA9635
intervalMeasure.cpp
- Committer:
- d_worrall
- Date:
- 2011-07-11
- Revision:
- 0:37bc70ca825c
- Child:
- 1:b56440e55747
File content as of revision 0:37bc70ca825c:
#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; bool b = false; void trig(){ //function to call upon interrupt db.locate(0); db.printf("%06d", t.read_ms()); if(b == false){ t.start(); b = true; } else { t.stop(); db.printf("06d", t.read_ms()); t.reset(); t.start(); } } int main() { trigger.mode(PullUp); //activate internal pull up (hardware specific) db.init(); db.cls(); //clear screen trigger.rise(&trig); //attach count() to interrupt on rising edge of trigger db.printf("%06d", t.read_ms()); }