import machine
from utime import sleep
BUTTON_START_ID = 16
def main():
s0 = machine.Pin(27, machine.Pin.OUT)
mux_in = machine.Pin(26, machine.Pin.IN, machine.Pin.PULL_DOWN)
b0 = machine.Pin(BUTTON_START_ID, machine.Pin.IN, machine.Pin.PULL_DOWN)
last_dev = -1
last_button_val = 0
while True:
binary_code = 0
for selector_val in range(2):
s0.value(selector_val % 2)
sleep(0.02)
binary_code += (pow(2, selector_val) * mux_in.value())
if last_dev != binary_code:
last_dev = binary_code
print(f'selected output: {last_dev}')
sleep(0.1)
if b0.value() != last_button_val:
last_button_val = b0.value()
print(f'button: {last_button_val}')
if __name__ == "__main__":
main()