Random on and off blinky for nRF-DK

main.cpp

Committer:
gkroussos
Date:
2018-05-31
Revision:
0:774078f45f9d

File content as of revision 0:774078f45f9d:

#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);
    }
}