Unicorn Hat did not work [SOLVED]


I bought unicorn hat yesterday at maker faire and installed it on my pi B+ and installed the software.
I tried this simple python program and expected one led to light up-


Instead 2 rows light up for a second and the turn off.
Is my unicorn defective?
Even demo program simple.py lights up random leds.


First: yay! Thanks for picking one up, and welcome to the forums.

Here are a few questions to root out the common problems with Unicorn HAT:

  • Which OS are you running on your Raspberry Pi
  • Have you updated it lately?
  • Have you tried it on a fresh Raspbian install ( this seems to work 100% of the time )

If you’re seeing LEDs light up, then it’s almost certainly not defective, but since the software driver uses a very convoluted ( but very necessary ) way of getting your Pi to output the signal that the Unicorn HAT LEDs require.

The signal actually uses the same hardware as analog audio, so the two things have a habit of conflicting from time to time. An unavoidably necessity of the Unicorn HAT’s sheer awesomeness :D


Hi there, took me some time to find the reason for a similar error: My unicorn hat from time to time showed a single or a few randomly colored LEDs. Eventually (when I started some of the unicorn hat examples) all the LEDs were showing random colors and would change in some unforeseen order.

My raspberry controls a robot. So I have some other hats on it, too (servo controller, motor controller). I assumed that they did not work together properly. But after a while I found the real reason: Whenever I develop the robot software, I boot it with a HDMI screen attached. But when the robot should drive around etc, I boot it without HDMI display. The error occured only when the raspi was booted without HDMI display. After a few searches in the WWW I found the reason: The sound driver (snd-bcm2835) usually uses HDMI audio output. But when HDMI is not connected, it falls back to GPIO Pin12 (BCM 18) audio, so this is when the unicorn hat did not work.

Solution was to remove (or comment out) the driver “snd-bcm2835” in /etc/modules.




this sounds like some mediaeval logic, something to justify burning a witch or hunting a unicorn… ;-) I am pretty happy with my unicorn hat (and all my other hats are doing I2C and therefore do not conflict with GPIO 12 (BCM 18). So I can enjoy the sheer awesomeness…



I usually fire up my Pi’s with an HDMI display detected, so I might have missed this obvious sound problem in testing. Interesting! From what I understood, having the snd-bcm2835 module loaded doesn’t cause any harm and it’s only when sound is actually playing, or a mixer device like PyGame’s is initialized that it all goes awry. I may be wrong!


I have experienced the same problem after a lot of hair pulling.

I have an HDMI-DVI adapter and hence no audio, so the audio defaults to elsewhere.

With snd-bcm2835 is not disabled the UnicornHat just goes crazy and displays utter randomness.

Is there some solution to this, which doesn’t disable audio? I am certainly wanting to use audio with the unicorn hat.

Thank you.


Unfortunately it’s completely impossible without additional hardware- both Analog Audio and the Unicorn HAT use the same physical PWM hardware within the Pi to generate the finite timings needed.

You could potentially use a USB audio output, or an HDMI audio extractor. A bit of a hassle, but it’s the only way I’m aware of.


OK, so you were suggesting that little five dollar audio USB adapter would do the trick. Perfect!