2022-04-26 16:00:29 +00:00
|
|
|
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
|
|
|
|
|
2022-04-26 19:33:41 +00:00
|
|
|
global buttonPin
|
|
|
|
buttonPin = digitalio.DigitalInOut(board.GP15)
|
|
|
|
buttonPin.direction = digitalio.Direction.INPUT
|
|
|
|
buttonPin.pull = digitalio.Pull.UP
|
|
|
|
|
|
|
|
global previousValue
|
|
|
|
previousValue = True
|
|
|
|
|
2022-04-26 16:00:29 +00:00
|
|
|
while True:
|
2022-04-26 19:33:41 +00:00
|
|
|
if buttonPin.value == False:
|
2022-08-12 00:06:17 +00:00
|
|
|
print("0x0")
|
2022-08-12 00:09:11 +00:00
|
|
|
time.sleep(0.1)
|
2022-04-26 19:33:41 +00:00
|
|
|
else:
|
|
|
|
if previousValue != clkPin.value:
|
|
|
|
if clkPin.value == False:
|
2022-08-12 00:10:21 +00:00
|
|
|
if dtPin.value == False:
|
|
|
|
print("1x1")
|
|
|
|
elif dtPin.value == True:
|
|
|
|
print("1x0")
|
|
|
|
time.sleep(0.1)
|
2022-05-03 17:36:43 +00:00
|
|
|
previousValue = clkPin.value
|