George Roussos
/
random-blinky
Random on and off blinky for nRF-DK
Diff: main.cpp
- Revision:
- 0:774078f45f9d
diff -r 000000000000 -r 774078f45f9d main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu May 31 15:33:24 2018 +0000 @@ -0,0 +1,20 @@ +#include "mbed.h" + +DigitalOut led1(LED1); +DigitalOut led2(LED2); +DigitalOut led3(LED3); + +// main() runs in its own thread in the OS +// (note the calls to wait below for delays) +int main() { + int myRandom; + while (true) { + myRandom = rand() % 100; + if (myRandom > 50) led1 = !led1; + led2 = !led2; + myRandom = rand() % 100; + if (myRandom > 50) led3 = !led3; + wait(0.5); + } +} +