thread example

main.cpp

Committer:
kaushalpkk
Date:
2018-07-12
Revision:
0:d8bfcd01100d

File content as of revision 0:d8bfcd01100d:

#include "mbed.h"
 
DigitalOut led1(LED1);
DigitalOut led2(LED2);
Thread thread;
 
void led2_thread() {
    while (true) {
        led2 = !led2;
        wait(1);
    }
}
 void led1_thread() {
    while (true) {
        led1 = !led1;
        wait(1);
    }
}
 
int main() {
    thread.start(led2_thread);
    thread.start(led1_thread);
    
    
    while (true) {
        led1 = !led1;
        wait(0.5);
    }
}