mbed Workshops
/
Workshop-1-Example-2
A ticker blinky implementation.
Diff: main.cpp
- Revision:
- 0:41a092c2e9d3
diff -r 000000000000 -r 41a092c2e9d3 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Sep 26 16:13:44 2016 +0000 @@ -0,0 +1,21 @@ +#include "mbed.h" + +Ticker flipper; +DigitalOut led1(LED1); +DigitalOut led2(LED2); + +void flip() { + led2 = !led2; +} + +int main() { + led2 = 1; + flipper.attach(&flip, 2.0); // call flip function every 2 seconds + + + // spin in a main loop. flipper will interrupt it to call flip + while(1) { + led1 = !led1; + wait(0.2); + } +} \ No newline at end of file