Repeating input infinitely after a single press /u/TheRealyst Python Education

Hello. Just trying to make a macropad for myself and getting a bit frustrated as I have not been able to find a solution to this even searching online which is surprising. I’m coding the first button and after saving the code, I press the button one time and it repeats the input indefinitely until I unplug it and plug it back in. I’ve looked at numberous tutorials and even copy and pasted different codes that people said works but I have the same issue. Please tell me what I’m doing incorrectly. With the below coding, I have the number 1 being pressed forever after I just press the key one time.

import time import usb_hid from adafruit_hid.keycode import Keycode from adafruit_hid.keyboard import Keyboard import board import digitalio btn1_pin = board.GP15 btn1 = digitalio.DigitalInOut(btn1_pin) btn1.direction = digitalio.Direction.INPUT btn1.pull = digitalio.Pull.DOWN keyboard = Keyboard(usb_hid.devices) while True: if btn1.value: print("button 1 pressed") keyboard.press(Keycode.ONE) time.sleep(0.1) keyboard.release(Keycode.ONE) time.sleep(0.1) 

submitted by /u/TheRealyst
[link] [comments]

​r/learnpython Hello. Just trying to make a macropad for myself and getting a bit frustrated as I have not been able to find a solution to this even searching online which is surprising. I’m coding the first button and after saving the code, I press the button one time and it repeats the input indefinitely until I unplug it and plug it back in. I’ve looked at numberous tutorials and even copy and pasted different codes that people said works but I have the same issue. Please tell me what I’m doing incorrectly. With the below coding, I have the number 1 being pressed forever after I just press the key one time. import time import usb_hid from adafruit_hid.keycode import Keycode from adafruit_hid.keyboard import Keyboard import board import digitalio btn1_pin = board.GP15 btn1 = digitalio.DigitalInOut(btn1_pin) btn1.direction = digitalio.Direction.INPUT btn1.pull = digitalio.Pull.DOWN keyboard = Keyboard(usb_hid.devices) while True: if btn1.value: print(“button 1 pressed”) keyboard.press(Keycode.ONE) time.sleep(0.1) keyboard.release(Keycode.ONE) time.sleep(0.1) submitted by /u/TheRealyst [link] [comments] 

Hello. Just trying to make a macropad for myself and getting a bit frustrated as I have not been able to find a solution to this even searching online which is surprising. I’m coding the first button and after saving the code, I press the button one time and it repeats the input indefinitely until I unplug it and plug it back in. I’ve looked at numberous tutorials and even copy and pasted different codes that people said works but I have the same issue. Please tell me what I’m doing incorrectly. With the below coding, I have the number 1 being pressed forever after I just press the key one time.

import time import usb_hid from adafruit_hid.keycode import Keycode from adafruit_hid.keyboard import Keyboard import board import digitalio btn1_pin = board.GP15 btn1 = digitalio.DigitalInOut(btn1_pin) btn1.direction = digitalio.Direction.INPUT btn1.pull = digitalio.Pull.DOWN keyboard = Keyboard(usb_hid.devices) while True: if btn1.value: print("button 1 pressed") keyboard.press(Keycode.ONE) time.sleep(0.1) keyboard.release(Keycode.ONE) time.sleep(0.1) 

submitted by /u/TheRealyst
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *