# Getting the Unicorn Hat up and running

**URL:** <https://forums.pimoroni.com/t/getting-the-unicorn-hat-up-and-running/114>\
**Category:** Support\
**Created:** [October 25, 2014, 9:57pm UTC](https://forums.pimoroni.com/t/getting-the-unicorn-hat-up-and-running/114 "2014-10-25T21:57:41Z")\
**Posts on this page:** 9\
**Page:** 2

<div class="post-metadata">

**Author:** ![gadgetoid](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/gadgetoid/32/13_2.png) [@gadgetoid](https://forums.pimoroni.com/u/gadgetoid)\
**Post date:** [November 16, 2014, 12:54pm UTC](https://forums.pimoroni.com/t/getting-the-unicorn-hat-up-and-running/114/21 "2014-11-16T12:54:58Z")

</div>

I’ve downloaded and set up RetroPie so I can try myself.

You could try cloning the UnicornHat GitHub repository and installing the ws2812 driver from there, try this:

```
https://github.com/pimoroni/unicornhat
cd unicornhat/python/ws2812
sudo python setup.py install
```

---

<div class="post-metadata">

**Author:** ![Mr\_A](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/mr_a/32/1333_2.png) [@Mr\_A](https://forums.pimoroni.com/u/Mr_A)\
**Post date:** [November 16, 2014, 1:03pm UTC](https://forums.pimoroni.com/t/getting-the-unicorn-hat-up-and-running/114/22 "2014-11-16T13:03:28Z")

</div>

Great stuff. Ok, I’ll give this a go. I’m just trying a vanilla RetroPie image and will try your script and other bits of advice to see if anything works.

Will report back.

---

<div class="post-metadata">

**Author:** ![Mr\_A](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/mr_a/32/1333_2.png) [@Mr\_A](https://forums.pimoroni.com/u/Mr_A)\
**Post date:** [November 16, 2014, 1:53pm UTC](https://forums.pimoroni.com/t/getting-the-unicorn-hat-up-and-running/114/23 "2014-11-16T13:53:10Z")

</div>

Ok, I have just used the vanilla RetroPie image (v2.3) and then ran your install script and everything works fine! The Unicorn Hat is working as expected.

Great news, but also a pain for me - something I have installed has obviously got an issue. Not sure what, but it looks like I may have to reinstall RetroPie from scratch if I want to use the Unicon Hat on my Pi.

I’m going to the last bit of advice you gave before my two replies to see if that fixes it - last chance saloon!

---

<div class="post-metadata">

**Author:** ![Mr\_A](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/mr_a/32/1333_2.png) [@Mr\_A](https://forums.pimoroni.com/u/Mr_A)\
**Post date:** [November 16, 2014, 4:18pm UTC](https://forums.pimoroni.com/t/getting-the-unicorn-hat-up-and-running/114/24 "2014-11-16T16:18:51Z")

</div>

I have now managed to get the Unicorn Hat working with Emulation Station installed. I’m not sure what I did differently, but I can get it to work!

What I now need to figure out is how to get Emulation Station to run a command when I launch a game. The idea being that when I play any NES game, I run sudo python [mario.py](http://mario.py) and then the Unicorn Hat displays the image (based on the show\_png.py script) and it displays a custom animation I created which is an 8 x 8 pixel logo of Mario that alternates to Luigi…

---

<div class="post-metadata">

**Author:** ![gadgetoid](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/gadgetoid/32/13_2.png) [@gadgetoid](https://forums.pimoroni.com/u/gadgetoid)\
**Post date:** [November 16, 2014, 4:54pm UTC](https://forums.pimoroni.com/t/getting-the-unicorn-hat-up-and-running/114/25 "2014-11-16T16:54:49Z")

</div>

If you can’t get emulation station to actively run a script, you could always run another script that polls the process list for each emulator ( might even be able to find the rom that’s been loaded in from the command line ) and updates accordingly.

Something like: ps aux | grep dgen

Or whatever the emulator binaries are called!

Glad you got it working- I’ve had plenty of problems I’ve fixed without quite figuring out how.

---

<div class="post-metadata">

**Author:** ![Mr\_A](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/mr_a/32/1333_2.png) [@Mr\_A](https://forums.pimoroni.com/u/Mr_A)\
**Post date:** [November 16, 2014, 4:56pm UTC](https://forums.pimoroni.com/t/getting-the-unicorn-hat-up-and-running/114/26 "2014-11-16T16:56:35Z")

</div>

Thanks - sounds like a plan! I’ve just shutdown now, but I’ll give it a go and see how it goes.

---

<div class="post-metadata">

**Author:** ![TimFromWales](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/timfromwales/32/81_2.png) [@TimFromWales](https://forums.pimoroni.com/u/TimFromWales)\
**Post date:** [December 8, 2014, 11:04am UTC](https://forums.pimoroni.com/t/getting-the-unicorn-hat-up-and-running/114/27 "2014-12-08T11:04:38Z")

</div>

I got the Unicorn at the weekend and its beautiful…

Had some fund with code found on github, making some changes looking for user inputs etc - quite impressed myself actually!

However - I only seemed to be able to run my .py code after rooting, typing “sudo su” in the shell.

Why is this?

---

<div class="post-metadata">

**Author:** ![gadgetoid](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/gadgetoid/32/13_2.png) [@gadgetoid](https://forums.pimoroni.com/u/gadgetoid)\
**Post date:** [December 8, 2014, 11:07am UTC](https://forums.pimoroni.com/t/getting-the-unicorn-hat-up-and-running/114/28 "2014-12-08T11:07:53Z")

</div>

Does it not work if you use: “sudo python [yourfile.py](http://yourfile.py)” ?

The method UnicornHat uses to actually drive the pixels involves some low-level memory twiddling that only the root user has access to. It’s a bit of a hassle, but there’s currently no way around it.

---

<div class="post-metadata">

**Author:** ![TimFromWales](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/timfromwales/32/81_2.png) [@TimFromWales](https://forums.pimoroni.com/u/TimFromWales)\
**Post date:** [December 8, 2014, 11:27am UTC](https://forums.pimoroni.com/t/getting-the-unicorn-hat-up-and-running/114/29 "2014-12-08T11:27:32Z")

</div>

Thanks for this - will try “sudo python [yourfile.py](http://yourfile.py)” later.

[Previous page](https://forums.pimoroni.com/t/getting-the-unicorn-hat-up-and-running/114.md?page=1)
