mbed Workshops
/
Workshop-1-Example-3
A threaded blinky implementation.
main.cpp
- Committer:
- sarahmarshy
- Date:
- 2016-09-26
- Revision:
- 0:04fa7fb0681e
File content as of revision 0:04fa7fb0681e:
#include "mbed.h" #include "rtos.h" DigitalOut led1(LED1); DigitalOut led2(LED2); void led2_thread(void const *args) { while (true) { led2 = !led2; Thread::wait(1000); } } int main() { //Create a thread to execute the function led2_thread Thread thread(led2_thread); //led2_thread is executing concurrently with main at this point while (true) { led1 = !led1; Thread::wait(500); } }