Skip to content

Instantly share code, notes, and snippets.

@lesp
Created September 24, 2014 19:11
Show Gist options
  • Save lesp/68545bde4cc79c7e53ce to your computer and use it in GitHub Desktop.
Save lesp/68545bde4cc79c7e53ce to your computer and use it in GitHub Desktop.
Unicorn HAT
import ws2812
from time import sleep
from random import randint
ws2812.init(64)
"""
while True:
for i in range(0,64):
ws2812.setPixelColor(i,128,64,64)
ws2812.show()
sleep(0.02)
ws2812.clear()
"""
x = randint(0,64)
y = randint(0,64)
z = randint(0,64)
while True:
ws2812.setPixelColor(x,255,0,0)
ws2812.show()
sleep(0.01)
ws2812.clear()
x = randint(0,64)
ws2812.setPixelColor(y,0,255,0)
ws2812.show()
sleep(0.01)
ws2812.clear()
y = randint(0,64)
ws2812.setPixelColor(z,0,0,255)
ws2812.show()
sleep(0.01)
ws2812.clear()
z = randint(0,64)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment