#include <Arduino.h>
#include <freertos/FreeRTOS.h>
#include <task.h>
#define LED1_PIN 13 // Assume LED1 is connected to pin 2
#define LED2_PIN 14 // Assume LED2 is connected to pin 4
void task1(void *pvParameters) {
(void)pvParameters;
for (;;) {
digitalWrite(LED1_PIN, HIGH); // Turn on LED1
vTaskDelay(pdMS_TO_TICKS(1000)); // Delay for 1 second
digitalWrite(LED1_PIN, LOW); // Turn off LED1
vTaskDelay(pdMS_TO_TICKS(1000)); // Delay for 1 second
}
}
void task2(void *pvParameters) {
(void)pvParameters;
for (;;) {
digitalWrite(LED2_PIN, HIGH); // Turn on LED2
vTaskDelay(pdMS_TO_TICKS(500)); // Delay for 500ms
digitalWrite(LED2_PIN, LOW); // Turn off LED2
vTaskDelay(pdMS_TO_TICKS(500)); // Delay for 500ms
}
}
void setup() {
pinMode(LED1_PIN, OUTPUT);
pinMode(LED2_PIN, OUTPUT);
xTaskCreatePinnedToCore(task1, "Task1", 1000, NULL, 1, NULL, APP_CPU_NUM);
xTaskCreatePinnedToCore(task2, "Task2", 1000, NULL, 1, NULL, APP_CPU_NUM);
}
void loop() {
// Empty. No need for any code here.
}