Luca Mottola
/
AthensFall19-BlinkThread
Blink using threads
Revision 0:f6371c0a2f6f, committed 2018-11-08
- Comitter:
- lmottola
- Date:
- Thu Nov 08 12:37:42 2018 +0000
- Commit message:
- Initial commit
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed-os.lib | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Nov 08 12:37:42 2018 +0000 @@ -0,0 +1,23 @@ +#include "mbed.h" + +DigitalOut led1(LED1); +DigitalOut led2(LED2); +Thread thread; + +void led2_thread() { + while (true) { + led2 = !led2; + wait(1); + } +} + +int main() { + // Create a thread to execute the function led2_thread + thread.start(led2_thread); + // Now led2_thread is executing concurrently with main at this point + + while (true) { + led1 = !led1; + wait(0.5); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Thu Nov 08 12:37:42 2018 +0000 @@ -0,0 +1,1 @@ +https://github.com/armmbed/mbed-os/