Dependencies: dispBoB mbed PCA9635
counter.cpp
00001 #include "mbed.h" 00002 #include "dispBoB.h" 00003 00004 dispBoB db(p28, p27, p26); //instantiate a dispBoB object 00005 InterruptIn trigger(p12); //set up the trigger as an external interrupt 00006 00007 int counter = 0; //initialise counter object to zero 00008 00009 void count(){ //function to call upon interrupt 00010 counter++; //increment counter object 00011 db.locate(0); 00012 db.printf("%06d", counter); //print counter info to dispBoB 00013 } 00014 00015 int main() { 00016 trigger.mode(PullUp); //activate internal pull up (hardware specific) 00017 db.init(); 00018 db.cls(); //clear screen 00019 trigger.rise(&count); //attach count() to interrupt on rising edge of trigger 00020 db.printf("%06d", counter); //display an inital count "000000" 00021 }
Generated on Wed Jul 13 2022 07:10:59 by 1.7.2