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:
- okano
- Date:
- 2012-03-26
- Revision:
- 0:d5cc979e064a
File content as of revision 0:d5cc979e064a:
#include "mbed.h"
// A class for flip()-ing a DigitalOut
class Flipper {
public:
Flipper(PinName pin) : _pin(pin) {
_pin = 0;
}
void flip() {
_pin = !_pin;
}
private:
DigitalOut _pin;
};
DigitalOut led1(LED1);
Flipper f(LED2);
Flipper f3(LED3);
Ticker t0;
Ticker t1;
Ticker t2;
Ticker t3;
int main() {
t0.attach(&f3, &Flipper::flip, 0.7); // the address of the object, member function, and interval
t1.attach(&f, &Flipper::flip, 0.5); // the address of the object, member function, and interval
// spin in a main loop. flipper will interrupt it to call flip
while(1) {
led1 = !led1;
wait(0.2);
}
}