#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_err.h"
#include "button.h"
#include "led.h"
static bool led_is_on = false;
static void button_pressed(void)
{
if (led_is_on) {
ledOff();
} else {
ledOn();
}
led_is_on = !led_is_on;
}
void app_main(void)
{
ESP_ERROR_CHECK(led_init());
ESP_ERROR_CHECK(button_init(button_pressed));
BaseType_t task_status = xTaskCreate(
button_task,
"button_task",
2048,
NULL,
5,
NULL
);
if (task_status != pdPASS) {
printf("ERROR: Button task could not be created\n");
abort();
}
}Loading
esp32-s3-devkitc-1
esp32-s3-devkitc-1