Im new to the RPi, Python and Unicorn hat, some I was pretty pleased when I got it up and running quickly. I tinkered around a bit and tried a few of the samples. I saw the rainbow didn’t show all the colours, so I thought I would knock up my code to see if I could make something that would and here’s what I came up with…
import unicornhat as u import time import math as math u.brightness(0.2) r=[0,0,0,0,0,0,0,0] g=[0,0,0,0,0,0,0,0] b=[0,0,0,0,0,0,0,0] def shift(l,n): return l[n:]+l[:n] freq = 0.1 while True: for i in range(64): r = shift(r,1) b = shift(b,1) g = shift(g,1) r = int(math.sin(freq*i+0)*127+128); g = int(math.sin(freq*i+2)*127+128); b = int(math.sin(freq*i+4)*127+128); for x in range(8): for y in range(8): u.set_pixel(x, y, r[x], g[x], b[x]) u.show()
setting freq to 0.05 and i to range 128, and putting a time.sleep(0.1) after the u.show() will give a much more subtle fade between the colours.