Oliver Ainhirn
/
81_Thread_03
version3 mit 4 Leds
main.cpp
- Committer:
- corsa1600
- Date:
- 2019-03-14
- Revision:
- 2:7b860e46bf67
- Parent:
- 1:f17f1b284f68
File content as of revision 2:7b860e46bf67:
#include "mbed.h" DigitalOut led1(LED1); DigitalOut led2(LED2); DigitalOut led3(LED3); DigitalOut led4(LED4); Thread thread(osPriorityHigh); Thread thread3(osPriorityNormal); Thread thread4(osPriorityLow); void led2_thread() { double x, y =1.99, z=0.99; while (true) { led2 = !led2; wait(0.5); for (int j=0; j<100; j++) for (int i=0; i<100; i++) x = y*z+x; } } void led3_thread() { double x, y =1.99, z=0.99; while (true) { led3 = !led3; wait(0.5); for (int j=0; j<100; j++) for (int i=0; i<100; i++) x = y*z+x; } } void led4_thread() { double x, y =1.99, z=0.99; while (true) { led4 = !led4; wait(0.5); for (int j=0; j<100; j++) for (int i=0; i<100; i++) x = y*z+x; } } int main() { thread.start(led2_thread); thread3.start(led3_thread); thread4.start(led4_thread); osThreadSetPriority(osThreadGetId(), osPriorityBelowNormal); double x, y=1.99, z=0.99; while (true) { led1 = !led1; wait(0.25); for (int j=0; j<200; j++) for (int i=0; i<200; i++) x = y*z+x; } }