Created
November 26, 2022 02:45
-
-
Save mzyy94/4478525367c5f62d9c849b72ebd82deb to your computer and use it in GitHub Desktop.
Adafruit Neo Trinkey
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import board | |
import neopixel | |
import touchio | |
import usb_hid | |
from adafruit_hid.keyboard import Keyboard | |
from adafruit_hid.keycode import Keycode | |
from rainbowio import colorwheel | |
pixels = neopixel.NeoPixel(board.NEOPIXEL, 4) | |
touch0 = touchio.TouchIn(board.TOUCH1) | |
touch1 = touchio.TouchIn(board.TOUCH2) | |
kbd = Keyboard(usb_hid.devices) | |
def rainbow(): | |
for j in range(16): | |
for i in range(len(pixels)): | |
idx = int(i * 16 + j * 12) | |
pixels[i] = colorwheel(idx & 255) | |
pixels.show() | |
time.sleep(0.01) | |
while True: | |
if touch0.value or touch1.value: | |
rainbow() | |
pixels.fill((0, 0, 0)) | |
if touch0.value or touch1.value: | |
kbd.send(Keycode.KEYPAD_ONE) | |
kbd.send(Keycode.KEYPAD_TWO) | |
kbd.send(Keycode.KEYPAD_THREE) | |
kbd.send(Keycode.RETURN) | |
time.sleep(1) | |
time.sleep(0.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment