Signal mit mehrere LEDs

main.cpp

Committer:
corsa1600
Date:
8 months ago
Revision:
0:4ab541d4cb3b

File content as of revision 0:4ab541d4cb3b:

#include "mbed.h"

Thread thread;
Thread thread2;
DigitalOut led(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);

void led_thread() {
    while (true) {
        // Signal flags that are reported as event are automatically cleared.
        Thread::signal_wait(0x1);
        led = !led;
        Thread::signal_wait(0x2);
        led3 = !led3;
    }
}

void led_thread2() {
    while (true) {
        // Signal flags that are reported as event are automatically cleared.
        Thread::signal_wait(0x2);
        led2 = !led2;
    }
}
int main (void) {
    thread.start(callback(led_thread));
    thread2.start(callback(led_thread2));

    while (true) {
        wait(1);
        thread.signal_set(0x1);
        wait(1);
        thread.signal_set(0x2);
        wait(1);
        thread2.signal_set(0x2);
    }
    
   
}