#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
volatile bool button_pressed = false;
void buttonIsPressed(void *args)
{
button_pressed = true;
}
void app_main() {
gpio_config_t button_config = {
.pin_bit_mask = 1 << 4,
.mode = GPIO_MODE_INPUT,
.pull_up_en = GPIO_PULLUP_ENABLE,
.pull_down_en = GPIO_PULLDOWN_DISABLE,
.intr_type = GPIO_INTR_NEGEDGE
};
gpio_config(&button_config);
gpio_install_isr_service(0);
gpio_isr_handler_add(GPIO_NUM_4, buttonIsPressed, NULL);
while (1) {
printf("GPIO 4 = %d\n", gpio_get_level(GPIO_NUM_4));
vTaskDelay(500 / portTICK_PERIOD_MS);
}
}