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?
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:
So, the unicornhathd.set_led() function takes the following variables: x, y, r, g, b where x and y are the coordinates of the pixel from the top left corner beginning at 0, 0, and r, g, 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 :)
Just a quick note to say that it’s set_pixel, not 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.
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:
import unicornhathd
import time
unicornhathd.brightness(0.5)
unicornhathd.rotation(0)
while True:
for x in range(16):
for y in range(16):
unicornhathd.set_pixel(x, y, 255, 50, 100)
unicornhathd.show()
time.sleep(0.25)
unicornhathd.clear()
unicornhathd.show()
time.sleep(0.25)
(Please note I’m typing this on my phone and so the spacing isn’t correct here)
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… 😳