#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#define BUTTON_PIN GPIO_NUM_3
void button_task(void *arg) {
gpio_pad_select_gpio(BUTTON_PIN);
gpio_set_direction(BUTTON_PIN, GPIO_MODE_INPUT);
gpio_set_pull_mode(BUTTON_PIN, GPIO_PULLUP_ONLY);
while (1) {
int button_state = gpio_get_level(BUTTON_PIN);
printf("Button state: %d\n", button_state);
vTaskDelay(pdMS_TO_TICKS(1000));
}
}
void app_main() {
xTaskCreate(button_task, "button_task", 2048, NULL, 10, NULL);
}