Modify the BlinkThreadCallback example so you run two threads that blink different LEDs once per second by waiting for each other
Diff: main.cpp
- Revision:
- 0:11ca69d691b7
- Child:
- 1:30693312f670
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Nov 11 15:55:24 2018 +0000 @@ -0,0 +1,19 @@ +#include "mbed.h" + +Thread thread; +DigitalOut led1(LED1); +DigitalOut led2(LED2); + +// Blink function toggles the led in a long running loop +void blink(DigitalOut *led) { + *led = !*led; + wait(1); +} + +int main() { + while(true){ + thread.start(callback(blink, &led1)); + thread.join(); + thread.start(callback(blink, &led2)); + } +}