// Incluimos la biblioteca necesaria para el ESP32
#include <Arduino.h>
// Definimos los pines para los LEDs y los botones
#define LED_1 13
#define LED_2 12
#define LED_3 14
#define BOTON_1 0
#define BOTON_2 2
#define BOTON_3 4
void setup() {
// Se inicializan los pines de los LEDs como salidas
pinMode(LED_1, OUTPUT);
pinMode(LED_2, OUTPUT);
pinMode(LED_3, OUTPUT);
// Se inicializan los pines de los botones como entradas
pinMode(BOTON_1, INPUT);
pinMode(BOTON_2, INPUT);
pinMode(BOTON_3, INPUT);
}
void loop() {
// Leer el estado de los botones
int estadoBoton1 = digitalRead(BOTON_1);
int estadoBoton2 = digitalRead(BOTON_2);
int estadoBoton3 = digitalRead(BOTON_3);
// Si el botón 1 está presionado, encendemos el LED 1
if (estadoBoton1 == LOW) {
digitalWrite(LED_1, HIGH);
} else {
digitalWrite(LED_1, LOW);
}
// Si el botón 2 está presionado, encendemos el LED 2
if (estadoBoton2 == LOW) {
digitalWrite(LED_2, HIGH);
} else {
digitalWrite(LED_2, LOW);
}
// Si el botón 3 está presionado, encendemos el LED 3
if (estadoBoton3 == LOW) {
digitalWrite(LED_3, HIGH);
} else {
digitalWrite(LED_3, LOW);
}
}