Bought a pico unicorn recently but trying to code for it is not working. I installed pimoroni-pico-v1.19.12-micropython.uf2 and tried to run this code.
import picounicorn, utime, urandom
picounicorn.init()
while True:
x = urandom.randint(0, 15)
y = urandom.randint(0, 6)
r = urandom.randint(0, 255)
g = urandom.randint(0, 255)
b = urandom.randint(0, 255)
print(x, y, r, g, b)
picounicorn.set_pixel(x, y, r, g, b)
utime.sleep(0.1)
Pretty much all the pixels come on and stay on. The random numbers are generating correctly. I tried it at an even slower refresh rate with no change in behavior. I tried doing just one location and red picounicorn.set_pixel(3,3,255,0,0). Again, same behavior. Do I have a defective unicorn?
Your code seems to be working for me, although the first time I ran it the Pico Unicorn did seem to get into a strange glitchy state with most of the LEDs stuck on. After pressing ‘stop’ in Thonny and running it again it seemed to behave itself though.
Is the soldering on your Pico header solid and (the possibly obvious but occasionally valuable check) is the Unicorn Pack plugged into the Pico the right way round?
p.s. I’ve edited them in, but for future reference putting ``` at the beginning and end of your code block makes the forum display indents etc correctly :)
The Unicorn is on in the correct orientation and the Pico is the H model so it came with the headers on. Just to set expectations, I’m pretty new with micro controllers, but a long (decades!) time PC and programming geek - did it for a living until I retired.
Hmm - does stopping the code and restarting it help? (or closing and reopening Thonny and trying again). Can you post a photo or video showing what’s happening?
Sorry that didn’t help! Last thing that I can think of to check is that the pack is fully pushed down onto the Pico’s header pins?
If that doesn’t help you may have some faulty hardware - if you drop support a message with your order number they should be able to send you out a replacement: Contact Us for Raspberry Pi Technical Support - Pimoroni . If you include a link to this thread it should stop them asking you all the same questions again :)