from machine import Pin
import time
reset_button = Pin(14, Pin.IN, Pin.PULL_UP)
giro1_button = Pin(15, Pin.IN, Pin.PULL_UP)
giro2_button = Pin(16, Pin.IN, Pin.PULL_UP)
led_Q0 = Pin(17, Pin.OUT)
led_Q1 = Pin(18, Pin.OUT)
Q0 = 0
Q1 = 0
def calculate_Q0(A, B):
return (A + Q0) * (not R) * (not B)
def calculate_Q1(A, B):
return (B + Q1) * (not R) * (not A)
R = True
while True:
if not reset_button.value():
Q0 = 0
Q1 = 0
led_Q0.value(0)
led_Q1.value(0)
print("Reseteado: Q0 =", Q0, "Q1 =", Q1)
time.sleep(0.5)
if not giro1_button.value():
A = True
B = False
Q0 = calculate_Q0(A, B)
led_Q0.value(1)
led_Q1.value(0)
print("Giro 1 activado: Q0 =", Q0)
time.sleep(0.5)
if not giro2_button.value():
A = False
B = True
Q1 = calculate_Q1(A, B)
led_Q0.value(0)
led_Q1.value(1)
print("Giro 2 activado: Q1 =", Q1)
time.sleep(0.5)
time.sleep(0.1)