#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
//Definición de pines
#define PIN_BOTON GPIO_NUM_26
#define PIN_LED GPIO_NUM_14
void app_main() {
//Declarar pines como entrada/salida
gpio_set_direction(PIN_BOTON, GPIO_MODE_INPUT);
gpio_set_direction(PIN_LED, GPIO_MODE_OUTPUT);
//ACTIVAR RESISTENCIA PULLDOWN PARA EL BOTON
gpio_set_pull_mode(PIN_BOTON, GPIO_PULLDOWN_ONLY);
while(1){
int estado_boton = gpio_get_level(PIN_BOTON);
if (estado_boton == 1){
gpio_set_level(PIN_LED, 1);
printf("Led encendido\n");
}
else {
gpio_set_level(PIN_LED, 0);
printf("Led apagado\n");
}
vTaskDelay(pdMS_TO_TICKS(100));
}
}