Since I’m into making lights lately, I made a new one. Obviously most of the work was done by this guy on Thingiverse, but I did add a Raspberry Pi Zero with a Unicorn HAT for the fancy light effects.
Full video after the jump.
List of parts I used:
- 3D printer: This is the most… vital one. And probably the most expensive. If you don’t have one, find a buddy who does (but who’s not me).
- Raspberry Pi Zero (I used one without Wi-Fi, but if you buy one that does have it, you could probably program it to do even cooler stuff.): Pimoroni
- Unicorn PHAT: Pimoroni
My files:
https://www.thingiverse.com/thing:3143959
My code:
import time
import unicornhat as uh
import random
uh.set_layout(uh.PHAT)
while True:
uh.rotation(90)
uh.brightness(1)
u_width,u_height=uh.get_shape()
palette = [
(0x00,0x00,0x00),
(0x45,0x00,0x00),
(0x5d,0x1a,0x00),
(0x83,0x25,0x00),
(0xb3,0x3e,0x00),
(0xed,0x7d,0x00),
(0xfc,0xad,0x00),
(0xff,0xc6,0x36),
]
board = [[7 for i in range(8)] for j in range(8)]
board[random.randrange(8)][random.randrange(1)] = random.randrange(1)+6
board[random.randrange(8)][random.randrange(2)] = random.randrange(3)+3
for y in range(1,u_height):
for x in range(u_width):
tx = (x-1)+random.randrange(2)
if tx>7:
tx = tx-7
elif tx < 0:
tx = 7+tx
if board[tx][y-1] > 0:
board[x][y] = board[tx][y-1]-1
else:
board[x][y] = 0
for y in range(u_height):
for x in range(u_width):
(r, g, b) = palette[board[x][y]]
uh.set_pixel(x, y, r, g, b)
uh.show()
time.sleep(0.05)