Guest User

Untitled

a guest
Jul 23rd, 2022
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import board
  2. import time
  3. import keypad
  4. import usb_hid
  5. from adafruit_hid.keyboard import Keyboard
  6. from adafruit_hid.keycode import Keycode
  7. # setup
  8. kbd = Keyboard(usb_hid.devices)
  9. # send the key
  10.  
  11. keys = keypad.Keys((board.D23,), value_when_pressed=True, pull=False)
  12.  
  13. while True:
  14. intervalStart = time.monotonic()
  15. spin_counter = 0
  16. nonum = 0
  17. event = keys.events.get()
  18. while (time.monotonic()-intervalStart) < 5:
  19. event = keys.events.get()
  20. if event:
  21. spin_counter = spin_counter + 1
  22. print(spin_counter)
  23. print(time.monotonic()-intervalStart)
  24. if spin_counter >= 6:
  25. spin_counter = 0
  26. print(spin_counter)
  27. nonum = 1
  28. if nonum == 0:
  29. kbd.send(Keycode.KEYPAD_NUMLOCK)
Advertisement
Add Comment
Please, Sign In to add comment