const int LED_PIN = 4;
void midPrioTask(void *parameter) {
while (true) {
digitalWrite(LED_PIN, HIGH);
vTaskDelay(pdMS_TO_TICKS(500));
digitalWrite(LED_PIN, LOW);
vTaskDelay(pdMS_TO_TICKS(500));
}
}
void highPrioTask(void *parameter) {
TickType_t xLastWakeTime = xTaskGetTickCount();
while (true) {
Serial.println("HIGH - tijdkritisch");
vTaskDelayUntil(&xLastWakeTime, pdMS_TO_TICKS(500));
}
}
void lowPrioTask(void *parameter) {
while (true) {
Serial.println("LOW - achtergrond");
vTaskDelay(pdMS_TO_TICKS(2000));
}
}
void setup() {
pinMode(LED_PIN, OUTPUT);
Serial.begin(115200);
xTaskCreate(
highPrioTask, // welke functie
"highPrioTask", // naam (voor debuggen)
2048, // stack grootte in bytes
NULL, // parameter meegeven (nu niet nodig)
3, // prioriteit
NULL // handle (nu niet nodig)
);
xTaskCreate(
midPrioTask, // welke functie
"midPrioTask", // naam (voor debuggen)
2048, // stack grootte in bytes
NULL, // parameter meegeven (nu niet nodig)
2, // prioriteit
NULL // handle (nu niet nodig)
);
xTaskCreate(
lowPrioTask, // welke functie
"lowPrioTask", // naam (voor debuggen)
2048, // stack grootte in bytes
NULL, // parameter meegeven (nu niet nodig)
1, // prioriteit
NULL // handle (nu niet nodig)
);
}
void loop() {
// put your main code here, to run repeatedly:
}