![](/media/cache/profiles/8631e5b91354a846f00dbbf16ad94259.jpg.50x50_q85.jpg)
Thread example using mbed 5.7
main.cpp
- Committer:
- WilliamMarshQMUL
- Date:
- 2019-01-09
- Revision:
- 1:bbbe0fae16f3
- Parent:
- 0:83abbbeb9a3d
- Child:
- 2:b13b343de0f5
File content as of revision 1:bbbe0fae16f3:
// Simple Example fo use of Threads on mbed OS 5 // Only need to include mbed.h #include "mbed.h" // Variable for a second thread Thread thread; DigitalOut ledA(LED1); // Red LED DigitalOut ledB(LED2); // Green LED // This method is run in the second thread void ledB_thread() { while (true) { wait(0.25); ledB = !ledB; } } // This is the main thread int main (void) { ledA = 1 ; // off ledB = 1 ; // off // start the second thread thread.start(callback(ledB_thread)); while (true) { wait(0.4); ledA = !ledA; } }