Skip to content

Instantly share code, notes, and snippets.

@nickwebcouk
Created January 22, 2022 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickwebcouk/88b994cab08937066a7d8ffc82165324 to your computer and use it in GitHub Desktop.
Save nickwebcouk/88b994cab08937066a7d8ffc82165324 to your computer and use it in GitHub Desktop.
#!/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