29 lines
737 B
Python
29 lines
737 B
Python
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.1)
|
|
else:
|
|
if previousValue != clkPin.value:
|
|
if clkPin.value == False:
|
|
print("1x"+str(dtPin.value))
|
|
previousValue = clkPin.value
|