#include <Arduino.h>
#include "Arduino_FreeRTOS.h"
#include "task.h"
#define LED_PIN 13 // Change this to your LED pin
TaskHandle_t blinkTaskHandle = NULL;
void blinkTask(void *pvParameters) {
int count = 0;
while (1) {
digitalWrite(LED_PIN, HIGH);
count ++;
vTaskDelay(pdMS_TO_TICKS(500)); // 500ms on
digitalWrite(LED_PIN, LOW);
vTaskDelay(pdMS_TO_TICKS(500)); // 500ms off
if (count == 5) {
Serial.println("Blink task completed, deleting task...");
vTaskDelete(blinkTaskHandle); // Delete the task
}
}
}
void setup() {
Serial.begin(115200);
pinMode(LED_PIN, OUTPUT);
xTaskCreate(
blinkTask, // Task function
"BlinkTask", // Task name
1000, // Stack size
NULL, // Task parameters
1, // Priority
&blinkTaskHandle // Task handle
);
}
void loop() {
// Main loop does nothing
}