#=========================
#Echo por: Lopito96woof
#=========================
from machine import Pin
import time
# =========================
# CONFIGURACION BOTONES
# =========================
button_pins = [
0, 1, 2, 3, 4,
5, 6, 7, 8, 9,
10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20,
21, 22, 26, 27, 28
]
buttons = []
last_states = []
# Crear entradas pull-up
for pin_num in button_pins:
btn = Pin(pin_num, Pin.IN, Pin.PULL_UP)
buttons.append(btn)
last_states.append(btn.value())
print("MFD TEST INICIADO")
time.sleep(1)
# =========================
# LOOP PRINCIPAL
# =========================
while True:
for i in range(len(buttons)):
current = buttons[i].value()
# Detectar cambio
if current != last_states[i]:
if current == 0:
print("JOY_BTN{}".format(i + 1))
last_states[i] = current
time.sleep_ms(20)
time.sleep_ms(1)