Skip to content

Instantly share code, notes, and snippets.

@gwthompson
Forked from todbot/trinkey_dance_code.py
Created April 29, 2021 22:35
Show Gist options
  • Save gwthompson/6d35779c40fbac38e1b40374ef92c442 to your computer and use it in GitHub Desktop.
Save gwthompson/6d35779c40fbac38e1b40374ef92c442 to your computer and use it in GitHub Desktop.
Trinkey Dance Party : fun pulsing colors for NeoTrinkey
# 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