Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import board
- import time
- import keypad
- import usb_hid
- from adafruit_hid.keyboard import Keyboard
- from adafruit_hid.keycode import Keycode
- # setup
- kbd = Keyboard(usb_hid.devices)
- # send the key
- keys = keypad.Keys((board.D23,), value_when_pressed=True, pull=False)
- while True:
- intervalStart = time.monotonic()
- spin_counter = 0
- nonum = 0
- event = keys.events.get()
- while (time.monotonic()-intervalStart) < 5:
- event = keys.events.get()
- if event:
- spin_counter = spin_counter + 1
- print(spin_counter)
- print(time.monotonic()-intervalStart)
- if spin_counter >= 6:
- spin_counter = 0
- print(spin_counter)
- nonum = 1
- if nonum == 0:
- kbd.send(Keycode.KEYPAD_NUMLOCK)
Advertisement
Add Comment
Please, Sign In to add comment