Pan-Tilt HAT review
By Russell Barnes. Posted

A Raspberry Pi camera stand with horizontal and vertical motion servos
Advertisement
The desktop computer you've been waiting for: Raspberry Pi 500+
The Raspberry Pi Camera Module is one of the best accessories you can get, enabling cheap photography on the Pi. But it doesn’t sit upright on its own – a stand is required.
The Pan-Tilt HAT fulfils this function and a whole lot more. The Camera Module is mounted on the end of a robotic arm that sits on top of the HAT. Thanks to the arm’s horizontal and vertical joints, the camera can be angled precisely by the two servo motors.
The full article can be found in The MagPi 54 and was written by Lucy Hattersley.
The finished effect is adorably cute, instantly imbuing your Raspberry Pi with personality as it looks around the room.
It’s really useful too. You could set the Pan-Tilt HAT up to monitor a room, and then use VNC or SSH to adjust its viewing position remotely.
Alternatively, you can set up a Raspberry Pi with face-tracking software and connect it to the Pan-Tilt HAT. Pimoroni, the HAT’s makers, also suggest mounting it on top of a robot for a set of eyes.
Setting it up
First, you have to set the HAT up. Fortunately, there is an online setup guide.
The board has a GPIO connection on one side, and servo connections on the other. The two sets of cables on the arm are connected to Servo 1 and Servo 2 on the board (1 for pan, 2 for tilt). A third servo channel can be used to control an optional NeoPixel strip for lighting.
Camera control
You can download all of the code from Pimoroni’s GitHub page. You need to install the pantilthat module to access the controls.
After importing the pantilthat library in Python, you use pan() and tilt() methods to change the camera position. These accept any value between -90 and 90. To set the camera straight forward, for example, you would use:
pantilthat.pan(0) pantilthat.tilt(0)
To look up by 45 degrees, use:
pantilthat.tilt(-45)
To look all the way to the camera’s left, you’d put:
pantilthat.pan(90)
We would have dearly loved more software examples. There are ones for motion and NeoPixels, but none for recording from the camera or face-tracking. A few more sample programs and it’d be perfect.
Even so, we had a lot of fun setting up the Pan-Tilt HAT and look forward to researching and coding a face-tracking program.
Last word
4/5
A highly enjoyable and extremely cute accessory. With a bit of research, you should be able to create some fun things with it.

Russell runs Raspberry Pi Press, which includes The MagPi, Hello World, HackSpace magazine, and book projects. He’s a massive sci-fi bore.
Subscribe to Raspberry Pi Official Magazine
Save up to 37% off the cover price and get a FREE Raspberry Pi Pico 2 W with a subscription to Raspberry Pi Official Magazine.
More articles

Raspberry Pi 500+ in Raspberry Pi Official Magazine issue 158
We’re quite taken with Raspberry Pi 500+. But when you don’t need all that processing power, and just want a board that will make a plastic skeleton jump around in a terrifying manner, you’ll find Raspberry Pi Pico more than up to the job. There’s more terror in the magazine (which is only right as […]
Read more →

Win one of five Raspberry Pi SSD 1TB
Raspberry Pi prides itself on high quality hardware, and this 1TB Raspberry Pi SSD is no different. You can use it with a standard Raspberry Pi or even in your desktop PC – the choice is yours. We have five to give away and you can enter below Win 1 of 5 Raspberry Pi SSD […]
Read more →

Dual-screen cyberdeck
Twin screens mean you can code on one screen while watching David Bowie’s 1978 Musikladen show on the other.
Read more →
Sign up to the newsletter
Get every issue delivered directly to your inbox and keep up to date with the latest news, offers, events, and more.