Dependencies:   dispBoB mbed PCA9635

Committer:
d_worrall
Date:
Fri Jul 08 14:55:33 2011 +0000
Revision:
0:43293cba961c
Child:
1:0b80876face4
version1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
d_worrall 0:43293cba961c 1 #include "mbed.h"
d_worrall 0:43293cba961c 2 #include "dispBoB.h"
d_worrall 0:43293cba961c 3
d_worrall 0:43293cba961c 4 dispBoB db(p28, p27, p26); //instantiate a dispBoB object
d_worrall 0:43293cba961c 5 InterruptIn trigger(p12); //set up the trigger as an external interrupt
d_worrall 0:43293cba961c 6
d_worrall 0:43293cba961c 7 int counter = 0; //initialise counter object to zero
d_worrall 0:43293cba961c 8
d_worrall 0:43293cba961c 9 void count(){ //function to call upon interrupt
d_worrall 0:43293cba961c 10 counter++; //increment counter object
d_worrall 0:43293cba961c 11 db.locate(0);
d_worrall 0:43293cba961c 12 db.printf("%06d", counter); //print counter info to dispBoB
d_worrall 0:43293cba961c 13 }
d_worrall 0:43293cba961c 14
d_worrall 0:43293cba961c 15 int main() {
d_worrall 0:43293cba961c 16 trigger.mode(PullUp); //activate internal pull up (hardware specific)
d_worrall 0:43293cba961c 17 db.cls(); //clear screen
d_worrall 0:43293cba961c 18 trigger.rise(&count); //attach count() to interrupt on rising edge of trigger
d_worrall 0:43293cba961c 19 db.printf("%06d", counter); //display an inital count "000000"
d_worrall 0:43293cba961c 20 }