const int red = 2;    // Red LED on GPIO 2
const int yellow = 0; // Yellow LED on GPIO 0
const int green = 4;  // Green LED on GPIO 4

void task1(void *parameters) {
  for (;;) {
    digitalWrite(red, HIGH);
    vTaskDelay(1000 / portTICK_PERIOD_MS);
    digitalWrite(red, LOW);
    vTaskDelay(1000 / portTICK_PERIOD_MS);
  }
}

void task2(void *parameters) {
  for (;;) {
    digitalWrite(yellow, HIGH);
    vTaskDelay(500 / portTICK_PERIOD_MS);
    digitalWrite(yellow, LOW);
    vTaskDelay(500 / portTICK_PERIOD_MS);
  }
}

void task3(void *parameters) {
  for (;;) {
    digitalWrite(green, HIGH);
    vTaskDelay(150 / portTICK_PERIOD_MS);
    digitalWrite(green, LOW);
    vTaskDelay(150 / portTICK_PERIOD_MS);
  }
}

void setup() {
  pinMode(red, OUTPUT);
  pinMode(yellow, OUTPUT);
  pinMode(green, OUTPUT);

  xTaskCreate(task1, "Task 1", 1000, NULL, 1, NULL);
  xTaskCreate(task2, "Task 2", 1000, NULL, 1, NULL);
  xTaskCreate(task3, "Task 3", 1000, NULL, 1, NULL);
}

void loop() {
  // The loop function is empty, as FreeRTOS tasks are used to control LEDs.
}