from machine import Pin
from time import sleep
ledverde = Pin(21, Pin.OUT)
ledamarrillo = Pin(20, Pin.OUT)
ledrojo = Pin(19, Pin.OUT)
boton_1 = Pin(28, Pin.IN, Pin.PULL_UP)
boton_2 = Pin(27, Pin.IN, Pin.PULL_UP)
memoria = 0
while True:
if boton_1.value() == 0 and memoria == 0:
memoria = not memoria
if memoria == 1:
ledamarrillo.value(1)
ledverde.value(1)
ledrojo.value(1)
print("encendido")
elif boton_2.value() == 0 and memoria == 1:
memoria = not memoria
if memoria == 0:
ledamarrillo.value(0)
ledverde.value(0)
ledrojo.value(0)
print("apagado")
sleep (0.5)