from machine import Pin
import time
A = Pin(0, Pin.IN, Pin.PULL_DOWN)
B = Pin(1, Pin.IN, Pin.PULL_DOWN)
R = Pin(2, Pin.IN, Pin.PULL_DOWN)
q0 = Pin(16, Pin.OUT)
q1 = Pin(17, Pin.OUT)
Estado_Q0 = 0
Estado_Q1 = 0
q0.value(Estado_Q0)
q1.value(Estado_Q1)
while True:
a = not A.value()
b = not B.value()
r = not R.value()
Estado_Q0 = (a or Estado_Q0) and (not r and not b)
Estado_Q1 = (b or Estado_Q1) and (not r and not a)
q0.value(Estado_Q0)
q1.value(Estado_Q1)
time.sleep(0.1)