/*
The original code:
https://microcontrollerslab.com/use-freertos-arduino/
Modified by Barbu Vulc!
January 4th, 2023
*/
//RTOS = Real-time operating system
//FreeRTOS site: https://www.freertos.org/
//FreeRTOS library:
#include <Arduino_FreeRTOS.h>
//Variables for buzzer & first 3 LEDs!
const int buzzer = 7; //Buzzer
const int LED1 = 8; //Red LED
const int LED2 = 9; //Yellow LED
const int LED3 = 10; //Green LED
/*
* I named this 'extender' (see below) because I can optionally...
* ...put a 4th task to this LED! Now is task-free! :))
*/
const int extender = 11; //Blue LED
void setup() {
Serial.begin(9600);
//LEDs' initialization!
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(extender, OUTPUT);
//Buzzer initialization!
pinMode(buzzer, OUTPUT);
/*
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);
}
//We don't need to use "loop" function here!
void loop() {}