Blinky disco lights for the K64F implemented with RTOS threads.

Dependencies:   mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "rtos.h"
00003 
00004 void blinkLED1(void const *args) {
00005     DigitalOut led1(LED1);
00006     while(true){
00007         led1 = !led1;
00008         Thread::wait(300);
00009     }
00010 }
00011 
00012 void blinkLED2(void const *args) {
00013     DigitalOut led2(LED2);
00014     while(true){
00015         led2 = !led2;
00016         Thread::wait(500);
00017     }
00018 }
00019 
00020 void blinkLED3(void const *args) {
00021     DigitalOut led3(LED3);
00022     while(true){
00023         led3 = !led3;
00024         Thread::wait(800);
00025     }
00026 }
00027 int main() {
00028 
00029     Thread thread1(blinkLED1);
00030     Thread thread2(blinkLED2);
00031     Thread thread3(blinkLED3);
00032 
00033     while (true) {
00034         Thread::wait(250);
00035     }
00036 
00037 }