parent
ff93288428
commit
b3f36c1d1f
28
code.py
28
code.py
|
@ -1 +1,27 @@
|
||||||
print("Hello World!")
|
import board
|
||||||
|
import digitalio
|
||||||
|
import time
|
||||||
|
import usb_hid
|
||||||
|
from adafruit_hid.consumer_control_code import ConsumerControlCode
|
||||||
|
from adafruit_hid.consumer_control import ConsumerControl
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
previousValue = True
|
||||||
|
consumer_control = ConsumerControl(usb_hid.devices)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
if previousValue != clkPin.value:
|
||||||
|
if clkPin.value == False:
|
||||||
|
if dtPin.value == False:
|
||||||
|
print('left')
|
||||||
|
consumer_control.send(ConsumerControlCode.VOLUME_DECREMENT)
|
||||||
|
else:
|
||||||
|
print('right')
|
||||||
|
consumer_control.send(ConsumerControlCode.VOLUME_INCREMENT)
|
||||||
|
previousValue = clkPin.value
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue