// Definición de los pines para los segmentos de los displays
const int segmentPins[] = { GPIO_NUM_5, GPIO_NUM_0, GPIO_NUM_1, GPIO_NUM_2, GPIO_NUM_0, GPIO_NUM_0, GPIO_NUM_0 }; // d, e, f, g, a, b, c
const int digitPins[] = { GPIO_NUM_14, GPIO_NUM_4 }; // Pines de control de dígitos
const int buttonPin = GPIO_NUM_35; // Pin del pulsador para incrementar (SW1)
const int resetButtonPin = GPIO_NUM_37; // Pin del pulsador para reiniciar (SW2)
const int decrementButtonPin = GPIO_NUM_45; // Pin del pulsador para restar (SW3)
// Matriz para los números del 0 al 9 (en ánodo común: segment LOW = ON)
const byte numbers[10] = {
B11000000, // 0
B11111001, // 1
B10100100, // 2
B10110000, // 3
B10011001, // 4
B10010010, // 5
B10000010, // 6
B11111000, // 7
B10000000, // 8
B10010000 // 9
};
int counter = 0; // Variable para el contador
int lastButtonState = HIGH; // Estado anterior del botón para incrementar
int currentButtonState; // Estado actual del botón para incrementar
int lastResetButtonState = HIGH; // Estado anterior del botón de reinicio
int currentResetButtonState; // Estado actual del botón de reinicio
int lastDecrementButtonState = HIGH; // Estado anterior del botón para restar
int currentDecrementButtonState; // Estado actual del botón para restar
unsigned long lastDebounceTime = 0; // Tiempo de la última lectura de botón
unsigned long debounceDelay = 50; // Retardo para evitar rebotes