Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin env python
import random
import time
import unicornhathd
unicornhathd.brightness(0.6)
unicornhathd.clear()
while True:
for count in range(256):
timenow = time.time()
rowraw = count//16
ledraw = count - (16 * rowraw )
row = rowraw + 1
led = ledraw + 1
tvalue = random.uniform(0.5, 1.0)
status = random.randint(0,1)
timenew = time.time()
timeresult = timenew - timenow
if timeresult > status:
ledstatus = "OFF"
unicornhathd.set_pixel(rowraw, ledraw, 0, 0, 0)
unicornhathd.show()
unicornhathd.set_pixel(rowraw, ledraw, 51, 0, 0)
unicornhathd.show()
unicornhathd.set_pixel(rowraw, ledraw, 102, 0, 0)
unicornhathd.show()
unicornhathd.set_pixel(rowraw, ledraw, 153, 0, 0)
unicornhathd.show()
unicornhathd.set_pixel(rowraw, ledraw, 204, 0, 0)
unicornhathd.show()
unicornhathd.set_pixel(rowraw, ledraw, 255, 0, 0)
unicornhathd.show()
else:
ledstatus = "ON"
unicornhathd.set_pixel(rowraw, ledraw, 255, 0, 0)
unicornhathd.show()
unicornhathd.set_pixel(rowraw, ledraw, 204, 0, 0)
unicornhathd.show()
unicornhathd.set_pixel(rowraw, ledraw, 153, 0, 0)
unicornhathd.show()
unicornhathd.set_pixel(rowraw, ledraw, 102, 0, 0)
unicornhathd.show()
unicornhathd.set_pixel(rowraw, ledraw, 51, 0, 0)
unicornhathd.show()
unicornhathd.set_pixel(rowraw, ledraw, 0, 0, 0)
unicornhathd.show()
#print(row, led, status, tvalue, timeresult, ledstatus)
#unicornhathd.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment