Blink using Thread

main.cpp

Committer:
lmottola
Date:
2018-11-08
Revision:
0:f6371c0a2f6f

File content as of revision 0:f6371c0a2f6f:

#include "mbed.h"

DigitalOut led1(LED1);
DigitalOut led2(LED2);
Thread thread;

void led2_thread() {
    while (true) {
        led2 = !led2;
        wait(1);
    }
}

int main() {
    // Create a thread to execute the function led2_thread
    thread.start(led2_thread);
    // Now led2_thread is executing concurrently with main at this point

    while (true) {
        led1 = !led1;
        wait(0.5);
    }
}