# Raspi 3B with pan tilt hat and LED

**URL:** <https://forums.pimoroni.com/t/raspi-3b-with-pan-tilt-hat-and-led/14249>\
**Category:** Support\
**Created:** [June 14, 2020, 3:02pm UTC](https://forums.pimoroni.com/t/raspi-3b-with-pan-tilt-hat-and-led/14249 "2020-06-14T15:02:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![portugal](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/portugal/32/5486_2.png) [@portugal](https://forums.pimoroni.com/u/portugal)\
**Post date:** [June 14, 2020, 3:03pm UTC](https://forums.pimoroni.com/t/raspi-3b-with-pan-tilt-hat-and-led/14249/1 "2020-06-14T15:03:00Z")

</div>

Hi, As a novice with this equipment and no coding experience I thought I would give it a try. 3 months later and few few choice words I am no nearer programming this Pi 3B with pan tilt hat with NeoPixel Stick - 8 x 5050 RGBW LEDs – Cool White - ~6000K light recommended that fits the pan tilt unit. Can someone please give me a complete code/image that I can load onto my sd card pop in the Pi 3B and it works. I’m getting to the point of just to binning it. Is that feasible or just Pi in the sky?

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [June 14, 2020, 4:36pm UTC](https://forums.pimoroni.com/t/raspi-3b-with-pan-tilt-hat-and-led/14249/2 "2020-06-14T16:36:42Z")

</div>

The function reference is here.  
[http://docs.pimoroni.com/pantilthat/](http://docs.pimoroni.com/pantilthat/)  
It lists the python commands you need to use.  
If you post the code your using maybe we can see any errors.  
There are neopixel examples for the Pan Tilt here to try.

> **[pimoroni/pantilt-hat](https://github.com/pimoroni/pantilt-hat/tree/master/examples/neopixel)**
>
> Python library for the Pimoroni PanTilt servo and lighting HAT - pimoroni/pantilt-hat

I have a couple of pan tilts setup for use in Motion Eye OS, no NeoPixels in use here though.

---

<div class="post-metadata">

**Author:** ![portugal](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/portugal/32/5486_2.png) [@portugal](https://forums.pimoroni.com/u/portugal)\
**Post date:** [June 15, 2020, 1:33pm UTC](https://forums.pimoroni.com/t/raspi-3b-with-pan-tilt-hat-and-led/14249/3 "2020-06-15T13:33:05Z")

</div>

Thanks for the info, managed to get Raspi desktop loaded and carried out all updates and had it move on individual commands. I didn’t have a picture from the camera though or LED lights. I saw an old YouTube on this: [https://www.youtube.com/watch?v=wj2CmN\_dLQw&t=27s](https://www.youtube.com/watch?v=wj2CmN_dLQw&t=27s) I downloaded his commands and the camera came on, no lights though and no servos. From the accompanied chat, nobody could get the servos working by using the arrow keys on the keyboard. I was hopeful to get it moving using the keyboard arrow buttons. Anyone know how and can I hut download the commands and get the lights and camera to work?

---

<div class="post-metadata">

**Author:** ![alphanumeric](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/alphanumeric/32/2729_2.png) [@alphanumeric](https://forums.pimoroni.com/u/alphanumeric)\
**Post date:** [June 15, 2020, 3:16pm UTC](https://forums.pimoroni.com/t/raspi-3b-with-pan-tilt-hat-and-led/14249/4 "2020-06-15T15:16:21Z")

</div>

The code below is code I used to find presets for Motion Eye. As posted it will center the two servo’s and do a preview of what the camera is looking at. Changing the values in  
`pantilthat.pan(0)`  
and  
`pantilthat.tilt(0)`  
will change where the servo’s move too. It goes from -90 to +90.  
That video you linked to is using PWM directly from the Pi’s GPIO pins to control the servos. Its not going to work with the Pan Tilt Hat.

My pan tilts are setup to work via Action Buttons in the Motion Eye OS web interface. My camera runs headless and I access it via a Web Browser. The Web GUI has all the controls to take pictures or record video. Manually or by detecting motion in front of the camera. I added left right up down movement buttons and some preset positions. You can also add buttons to turn the LED’s on and off.

> [@Pan Tilt Hat Motion Eye OS action buttons](https://forums.pimoroni.com/t/pan-tilt-hat-motion-eye-os-action-buttons/12186):
>
> I’m trying to get my Pan Tilt Hat working in the latest Motion Eye. To do this you have to create Action Button Files and put them in a specific location. Problem is I can’t find that location /etc/motioneye as per here, There are three partitions / drives on the Motion Eye SD card, with etc folders on each one, none have a motioneye folder in them though? And which one is the right one? If anybody has done this, or is trying to do it, any help or insight you can offer will greatly be appr…

```auto
from picamera import PiCamera
from time import sleep
import pantilthat

pantilthat.pan(0)
pantilthat.tilt(0)

camera = PiCamera()
camera.rotation = 180
camera.resolution = (1280, 720)

camera.start_preview()
sleep(10)
camera.stop_preview()

```
