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:
- adasys
- Date:
- 2013-06-14
- Revision:
- 0:eef50401b8ae
File content as of revision 0:eef50401b8ae:
#include "mbed.h"
Serial pc(USBTX, USBRX);
// A class for flip()-ing a DigitalOut
class Flipper {
int ii;
public:
Flipper(PinName pin) : _pin(pin) {
_pin = 0;
ii = 0;
}
void flip() {
ii++;
if( ii > 4000 ) {
_pin = !_pin;
ii=0;
}
}
private:
DigitalOut _pin;
};
DigitalOut led(LED1);
DigitalOut led2(LED2);
Flipper f(LED3);
Ticker t;
int main() {
t.attach_us(&f, &Flipper::flip, 25 ); // the address of the object, member function, and interval
// 25 us = 40kHz
//led3 = 1;
// spin in a main loop. flipper will interrupt it to call flip
while(1) {
led = !led;
wait(0.5);
}
}