Quantcast
Channel: Support - Pimoroni Buccaneers
Viewing all articles
Browse latest Browse all 6856

Generating random colours (unicornhat)

$
0
0

@Bootnut wrote:

I am trying to generate random colours on my unicornhat using the following code

from random import randint
r = randint(0, 255)
g = randint(0, 255)
b = randint(0, 255)
unicornhat.set_pixel(6, 0, r, g, b)

the trouble with this is every now and then I get a bad colour that doesn't display on the unicornhat, I assume it is generating "0, 0, 0"

is there a better way, maybe only generate safe / approved colours

Posts: 4

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 6856

Trending Articles