this is a ping-pang blinky in 4 LED.
Fork of mbed-os-example-mbed5-blinky by
Diff: main.cpp
- Revision:
- 14:c4162b826d08
- Parent:
- 8:bb09890333fe
--- a/main.cpp Wed Oct 05 05:15:02 2016 +0100 +++ b/main.cpp Thu Oct 20 14:08:21 2016 +0000 @@ -1,12 +1,23 @@ #include "mbed.h" DigitalOut led1(LED1); +DigitalOut led2(LED2); +DigitalOut led3(LED3); +DigitalOut led4(LED4); // main() runs in its own thread in the OS // (note the calls to Thread::wait below for delays) int main() { + char a=1,b; while (true) { - led1 = !led1; + led1 = !(a^1); + led2 = !(a^2); + led3 = !(a^4); + led4 = !(a^8); + if (led1) b=1; + if (led4) b=0; + if (b) a=a<<1; + else a=a>>1; Thread::wait(500); } }