I recently got my Unicorn HAT HD 256 RGB from Pimoroni and I went through some example projects, I must say they are super cool. I am new to Python and have been searching the web for some good tutorials to begin with: Can you guys please guide me and point out few good tutorials to start programming my unicorn Hat HD?
It’s for the original Unicorn HAT, but still applies with a little modification: https://learn.pimoroni.com/tutorial/unicorn-hat/making-rainbows-with-unicorn-hat
Unicorn HAT HD works in basically the same way as both Unicorn HAT and Unicorn pHAT, which just have less LEDs. We’ve got a Getting Started with Unicorn pHAT tutorial that should give you some tips.
But to get you started, if you open a terminal on your Pi and type the following, then it will light the top left LED in white:
unicornhathd.set_led(0, 0, 255, 255, 255)
unicornhathd.set_led() function takes the following variables:
x, y, r, g, b where
y are the coordinates of the pixel from the top left corner beginning at 0, 0, and
b are red, green, and blue values from 0 to 255.
You can set any number of the pixels and then call
unicornhathd.show() to push the data to the Unicorn HAT HD and display it. There are some tips in that Unicorn pHAT tutorial on how to use
for loops to update groups of pixels all in one go too.
Just let us know if you need any more help, or if you have specific things you’d like to do. :-)
Thank you for the help. I am going to get back on my unicorn HAT HD today again and make some good pixel art.
Just one more quick question: Do I follow the same guidelines from unicorn HAT to light up rows and columns? Maybe draw a diagonal line :)
Thank you once again, Good Day!
Yup, the API of Unicorn HAT HD is basically identical to that of Unicorn HAT- save for the fact it has 16x16 pixels instead of 8x8.
Thank you for all the help. I have been busy with other projects and I will be working again on Unicorn HAT HD.
Just a quick note to say that it’s
set_led - with that minor edit to Sandy’s example above, that script turns on the pixel at the corner closest to the Ethernet port on a Pi 3.
For those already comfortable with programming, there’s a useful reference manual here:
Hey, I’ve tried the example for the Unicorn Hat but changed the imported device to unicornhathd and tried the example for making a range of pixels flash but presently it just flashes the one pixel (0, 0), then flashes the next pixel to it (0, 1) and so one until all 256 pixels have flashed and then repeats.
Here’s what I’m typing currently:
for x in range(16):
for y in range(16):
unicornhathd.set_pixel(x, y, 255, 50, 100)
(Please note I’m typing this on my phone and so the spacing isn’t correct here)
Am I missing a step?
Never mind, it was my mistake! I was due to the spacing I made in Thonny; the ‘unicornhadhd.show()’ was in-line with the set pixel command and should had been set inline with ‘for x in range(16):’ - just like in the example… 😳
Flashing like a little trooper now!