//FreeRTOS library:
#include <Arduino_FreeRTOS.h>
#define sensorPin A0
void setup() {
/*
Create 3 tasks with labels 'Task_1', 'Task_2' and 'Task_3' and
assign the priority as 1, 2 and 3 respectively.
*/
//'Neutral_Task' - the task-free function!
xTaskCreate(Task_1, "Task no. 1!", 100, NULL, 1, NULL);
xTaskCreate(Task_2, "Task no. 2!", 100, NULL, 2, NULL);
xTaskCreate(Task_3, "Task no. 3!", 100, NULL, 3, NULL);
xTaskCreate(Neutral_Task, "Neutral_Task!", 100, NULL, 0, NULL);
}
//The following function is Task1. We display the task label on Serial monitor.
static void Task_1(void* pvParameters) {
while (1) {
Serial.println(F("Task no. 1!"));
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
//Task 2
static void Task_2(void* pvParameters) {
while (1) {
Serial.println(F("Task no. 2!"));
vTaskDelay(1100 / portTICK_PERIOD_MS);
}
}
//Task 3
static void Task_3(void* pvParameters) {
while (1) {
Serial.println(F("Task no. 3!"));
vTaskDelay(1200 / portTICK_PERIOD_MS);
}
}
//Task 4 (the last one)!
//This is an extension which can be task-free!
static void Neutral_Task(void* pvParameters) {
while (1) {
Serial.println(F("Neutral_Task"));
delay(1300);
}
}
//We don't need to use "loop" function here!
void loop() {}