KeyboardInterrupt in pi pico project

Viewed 29

So i have been wanting to make a macro pad with the Raspberry Pi Pico for a while now and when i finally got it, it just decided to break. (Probably my fault)... Thonny gives me a KeyboardInterrupt and i dont know why. Here is the interrupt message and my code.

Traceback (most recent call last):
    File "<stdin>", line 27, in <module>
KeyboardInterrupt:

And here is my code:

import time
import board
import digitalio
import usb_hid
from adafruit_hid.keycode import Keycode
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
from adafruit_hid.consumer_control import ConsumerControl
from adafruit_hid.consumer_control_code import ConsumerControlCode

cc = ConsumerControl(usb_hid.devices)

keyboard = Keyboard(usb_hid.devices)

write_text = KeyboardLayoutUS(keyboard)

btn1_pin = board.GP0
btn1 = digitalio.DigitalInOut(btn1_pin)
btn1.direction = digitalio.Direction.INPUT
btn1.pull = digitalio.Pull.DOWN

while True:
    if btn1.value:
        keyboard.send(Keycode.CONTROL, Keycode.A)
        time.sleep(0.1)
        
    time.sleep(0.1)
0 Answers
Related