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.
Homepage
Example¶
two blinking leds
#include "mbed.h"
#include "task_scheduler.h"
Serial pc(USBTX, USBRX); // tx, r
class Foo {
DigitalOut myled1;
int counter;
public:
Foo(void) :myled1(LED1) { counter = 0; }
void alive_task(void) {
if (counter++ % 30000 == 0) {
myled1 = !myled1;
}
}
};
class Bar {
DigitalOut myled2;
public:
Bar(void) :myled2(LED2) {}
void control_task(void) {
myled2 = !myled2;
}
};
int main() {
Foo foo;
Bar bar;
SimpleTaskScheduler::TaskScheduler scheduler;
scheduler.create_continuous_task(&foo, &Foo::alive_task);
scheduler.create_periodic_task(&bar, &Bar::control_task, 1);
while(1) {
scheduler.update();
}
}