-
-
Save gwthompson/6d35779c40fbac38e1b40374ef92c442 to your computer and use it in GitHub Desktop.
Trinkey Dance Party : fun pulsing colors for NeoTrinkey
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
# Trinkey dance party | |
# 2021 @todbot | |
import time | |
import board | |
import neopixel | |
import random | |
leds = neopixel.NeoPixel(board.NEOPIXEL, 4, brightness=0.3, auto_write=False) | |
bpm = 130 | |
ms_per_beat = int(60e3 / bpm / 16) | |
i=0 | |
while True: | |
leds[0:] = [[max(i-8,0) for i in l] for l in leds] # fadeToBlackBy(8) | |
leds.show() | |
i = (i+1) % ms_per_beat | |
if i==0: | |
leds[0:] = [int(random.random() * 2**24) for l in leds] # each LED gets new random color | |
time.sleep(0.01) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment