Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- mab5449
- Date:
- 2017-01-19
- Revision:
- 0:8c7b073576c5
File content as of revision 0:8c7b073576c5:
#include "mbed.h"
class Counter {
public:
Counter(PinName pin) : _interrupt(pin) { // create the InterruptIn on the pin specified to Counter
_interrupt.rise(callback(this, &Counter::increment)); // attach increment function of this counter instance
}
void increment() {
_count++;
}
int read() {
return _count;
}
private:
InterruptIn _interrupt;
volatile int _count;
};
Counter counter(SW2);
int main() {
while(1) {
printf("Count so far: %d\n", counter.read());
wait(2);
}
}