V prvom kroku si nainštalujem FreeRTOS knižnicu do Arduina:
Sketch -> Include Library -> Manage Libraries


Zapojíme si naše arduino nano podľa obrázka nižšie:

Kód v cpp:
#include <Arduino_FreeRTOS.h>
void setup()
{
xTaskCreate(
TaskBlink
, (const portCHAR *)"Blink"
, 128 // Stack size
, NULL
, 2 // priority
, NULL );
xTaskCreate(
TaskBlink2
, (const portCHAR *)"Blink2"
, 128 // Stack size
, NULL
, 2 // priority
, NULL );
}
void loop()
{
}
void TaskBlink2(void *pvParameters) // This is a task.
{
(void) pvParameters;
pinMode(3, OUTPUT);
for (;;)
{
digitalWrite(3, HIGH); // turn the LED on (HIGH is the voltage level)
vTaskDelay( 300 / portTICK_PERIOD_MS ); // wait for one second
digitalWrite(3, LOW); // turn the LED off by making the voltage LOW
vTaskDelay( 300 / portTICK_PERIOD_MS ); // wait for one second
}
}
void TaskBlink(void *pvParameters) // This is a task.
{
(void) pvParameters;
pinMode(2, OUTPUT);
for (;;)
{
digitalWrite(2, HIGH); // turn the LED on (HIGH is the voltage level)
vTaskDelay( 1000 / portTICK_PERIOD_MS ); // wait for one second
digitalWrite(2, LOW); // turn the LED off by making the voltage LOW
vTaskDelay( 1000 / portTICK_PERIOD_MS ); // wait for one second
}
}







