import board import digitalio import time clkPin = digitalio.DigitalInOut(board.GP2) dtPin = digitalio.DigitalInOut(board.GP1) dtPin.direction= digitalio.Direction.INPUT clkPin.direction = digitalio.Direction.INPUT clkPin.pull = digitalio.Pull.UP dtPin.pull = digitalio.Pull.UP global buttonPin buttonPin = digitalio.DigitalInOut(board.GP15) buttonPin.direction = digitalio.Direction.INPUT buttonPin.pull = digitalio.Pull.UP global previousValue previousValue = True while True: if buttonPin.value == False: print("0x0") time.sleep(0.2) else: if previousValue != clkPin.value: if clkPin.value == False: if dtPin.value == False: print("1x1") elif dtPin.value == True: print("1x0") time.sleep(0.1) previousValue = clkPin.value