Professional Documents
Culture Documents
TH4.3
TH4.3
TH4.3
3
#include <Arduino_FreeRTOS.h>
// Kích thước stack của mỗi task
#define STACK_SIZE 250
for(;;) {
for (int i = 0; i <= 5; i++) {
Serial.println("Hello, world!");
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
// Notify Task2 to run
xTaskNotifyGive(Task2Handle);
// Wait for Task2 to suspend this task
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
}
}
void setup() {
// Khởi tạo cổng Serial để in ra màn hình
Serial.begin(9600);
// Tạo Task1
xTaskCreate(Task1, "Task1", STACK_SIZE, NULL, TASK_PRIORITY,
&Task1Handle);
// Tạo Task2
xTaskCreate(Task2, "Task2", STACK_SIZE, NULL, TASK_PRIORITY,
&Task2Handle);
void loop() {
}