assignment 4 exercise 2

main.cpp

Committer:
mcalzana
Date:
13 months ago
Revision:
0:4ec9b8d0fe3a

File content as of revision 0:4ec9b8d0fe3a:

#include "mbed.h"


DigitalOut led1(LED1);
DigitalOut led2(LED2);
//volatile bool running = true;

// Blink function toggles the led in a long running loop
void blink(DigitalOut *led) {
    *led = 1;
    wait(1);
    *led = 0;
    return;
}

// Spawns a thread to run blink for 5 seconds
int main() {
    while(true){
        Thread thread1;
        Thread thread2;
        thread1.start(callback(blink, &led1));
        thread1.join();
        thread2.start(callback(blink, &led2));
        thread2.join();
    }
}