#CONFIGURACION DEL HARDWARE
from machine import Pin
x = Pin(4, Pin.IN, Pin.PULL_UP)
o = Pin(19, Pin.OUT)
# RESET
estado_actual = 'E0'
# LAZO DE OPERACION
while True:
# ESTADO SIGUIENTE
if estado_actual == 'E0' and x.value() == 0:
estado_siguiente = 'E0'
elif estado_actual == 'E0' and x.value() == 1:
estado_siguiente ='E1'
elif estado_actual == 'E1':
estado_siguiente = 'E0'
# SALIDA
o_var = 0 if estado_actual == 'E1' else 1
o.value(o_var)
# IMPRIMIR CONDICIONES ACTUALES
print(f'Estado actual: {estado_actual}, Entrada: x={x.value()}, Salida: o={o.value()}')
input('Esperando <ENTER> para cambiar de estado')
estado_actual = estado_siguiente