#include <Arduino_FreeRTOS.h>
TaskHandle_t Task1_handle;
void setup() {
Serial.begin(9600);
xTaskCreate(Task1, "print task", 128, NULL, 2, &Task1_handle);
xTaskCreate(Task2, "print task", 128, NULL, 2, NULL);
}
void loop() {
// put your main code here, to run repeatedly:
}
void Task1 (void *pvParameters) {
while(1) {
if (ulTaskNotifyTake(
pdTRUE, //RTOS task notif value is reset to 0 before ulTNT exits
portMAX_DELAY)) //blocking time
{
Serial.println("Notification Received.");
}
}
}
void Task2 (void *pvParameters) {
while(1) {
//send task notification to task 1 while using its handle
xTaskNotifyGive(Task1_handle);
vTaskDelay(5000/portTICK_PERIOD_MS);
}
}