Dependencies: dispBoB mbed PCA9635
counter.cpp@1:0b80876face4, 2011-07-11 (annotated)
- Committer:
- d_worrall
- Date:
- Mon Jul 11 13:58:21 2011 +0000
- Revision:
- 1:0b80876face4
- Parent:
- 0:43293cba961c
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
d_worrall | 1:0b80876face4 | 1 | #include "mbed.h" |
d_worrall | 1:0b80876face4 | 2 | #include "dispBoB.h" |
d_worrall | 1:0b80876face4 | 3 | |
d_worrall | 1:0b80876face4 | 4 | dispBoB db(p28, p27, p26); //instantiate a dispBoB object |
d_worrall | 1:0b80876face4 | 5 | InterruptIn trigger(p12); //set up the trigger as an external interrupt |
d_worrall | 1:0b80876face4 | 6 | |
d_worrall | 1:0b80876face4 | 7 | int counter = 0; //initialise counter object to zero |
d_worrall | 1:0b80876face4 | 8 | |
d_worrall | 1:0b80876face4 | 9 | void count(){ //function to call upon interrupt |
d_worrall | 1:0b80876face4 | 10 | counter++; //increment counter object |
d_worrall | 1:0b80876face4 | 11 | db.locate(0); |
d_worrall | 1:0b80876face4 | 12 | db.printf("%06d", counter); //print counter info to dispBoB |
d_worrall | 1:0b80876face4 | 13 | } |
d_worrall | 1:0b80876face4 | 14 | |
d_worrall | 1:0b80876face4 | 15 | int main() { |
d_worrall | 1:0b80876face4 | 16 | trigger.mode(PullUp); //activate internal pull up (hardware specific) |
d_worrall | 1:0b80876face4 | 17 | db.init(); |
d_worrall | 1:0b80876face4 | 18 | db.cls(); //clear screen |
d_worrall | 1:0b80876face4 | 19 | trigger.rise(&count); //attach count() to interrupt on rising edge of trigger |
d_worrall | 1:0b80876face4 | 20 | db.printf("%06d", counter); //display an inital count "000000" |
d_worrall | 1:0b80876face4 | 21 | } |