#if CONFIG_FREERTOS_UNICORE
static const BaseType_t app_cpu = 0;
#else
static const BaseType_t app_cpu = 1;
#endif
//LED rates
static const int rate_1 = 500;
static const int rate_2 = 300;
// Pins
static const int led_pin = LED_BUILTIN;
// Task: blink an LED at rate 1.
void toggleLED_1(void* parameter) {
while(1) {
digitalWrite(led_pin, HIGH);
vTaskDelay(rate_1 / portTICK_PERIOD_MS);
digitalWrite(led_pin, LOW);
vTaskDelay(rate_1 / portTICK_PERIOD_MS);
}
}
// Task: blink an LED at rate 2.
void toggleLED_2(void* parameter) {
while(1) {
digitalWrite(led_pin, HIGH);
vTaskDelay(rate_2 / portTICK_PERIOD_MS);
digitalWrite(led_pin, LOW);
vTaskDelay(rate_2 / portTICK_PERIOD_MS);
}
}
void setup() {
// put your setup code here, to run once:
// Serial.begin(115200);
// Serial.println("Hello, ESP32!");
// Configure pin.
pinMode(led_pin, OUTPUT);
// Task to run forever.
xTaskCreatePinnedToCore(
toggleLED_1,
"Toggle LED 1",
1024,
NULL,
1,
NULL,
app_cpu);
xTaskCreatePinnedToCore(
toggleLED_2,
"Toggle LED 2",
1024,
NULL,
1,
NULL,
app_cpu);
}
void loop() {
// put your main code here, to run repeatedly:
// delay(10); // this speeds up the simulation
}