Circuit python won't work send keys with (HID)

20 views Asked by At

So when I push down on the keys that ive installed onto the pico they detected that its been pressed shown in the first picture. Keys detected

Even though it has been detected it doesn't send the key presses that are in the code related to it. (Code shown below)

`import timeimport digitalioimport boardimport usb_hidfrom adafruit_hid.keyboard import Keyboardfrom adafruit_hid.keycode import Keycode
keyboard = Keyboard(usb_hid.devices)
Key assaignments
Top left
btn1_pin = board.GP19
Up arrow
btn2_pin = board.GP20
Top right
btn3_pin = board.GP21
Left arrow
btn4_pin = board.GP6
Down arrow
btn5_pin = board.GP8
Right arrow
btn6_pin = board.GP7
btn1 = digitalio.DigitalInOut(btn1_pin)btn1.direction = digitalio.Direction.INPUTbtn1.pull = digitalio.Pull.DOWN
btn2 = digitalio.DigitalInOut(btn2_pin)btn2.direction = digitalio.Direction.INPUTbtn2.pull = digitalio.Pull.DOWN
btn3 = digitalio.DigitalInOut(btn3_pin)btn3.direction = digitalio.Direction.INPUTbtn3.pull = digitalio.Pull.DOWN
btn4 = digitalio.DigitalInOut(btn4_pin)btn4.direction = digitalio.Direction.INPUTbtn4.pull = digitalio.Pull.DOWN
btn5 = digitalio.DigitalInOut(btn5_pin)btn5.direction = digitalio.Direction.INPUTbtn5.pull = digitalio.Pull.DOWN
btn6 = digitalio.DigitalInOut(btn6_pin)btn6.direction = digitalio.Direction.INPUTbtn6.pull = digitalio.Pull.DOWN
keyboard = Keyboard(usb_hid.devices)
while True:if btn1.value:print("Button 1 pressed!")keyboard.send(Keycode.SHIFT, Keycode.ALT, Keycode.L)time.sleep(0.3)
    if btn2.value:
        print("Button 2 pressed!")
        keyboard.send(Keycode.SHIFT, Keycode.ALT, Keycode.L)
        time.sleep(0.3)
 
    if btn3.value:
        print("Button 3 pressed!")
        keyboard.send(Keycode.SHIFT, Keycode.ALT, Keycode.L)
        time.sleep(0.3)
  
    if btn4.value:
        print("Button 4 pressed!")
        keyboard.send(Keycode.SHIFT, Keycode.ALT, Keycode.L)
        time.sleep(0.3)
       
    if btn5.value:
        print("Button 5 pressed!")
        keyboard.send(Keycode.SHIFT, Keycode.ALT, Keycode.L)
        time.sleep(0.3)
        
    if btn6.value:
        print("Button 6 pressed!")
        keyboard.send(Keycode.SHIFT, Keycode.ALT, Keycode.L)
        time.sleep(0.3)

I checked if I had all the need modules install and as far as I know I have them.

I would also like to mention that I am new to all this so I might not have something or haven't noticed something simple

0

There are 0 answers