Pan-Tilt HAT review
By Russell Barnes. Posted
A Raspberry Pi camera stand with horizontal and vertical motion servos
Take back control of your online data, with Raspberry Pi.
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
Take Back Your Clound in Raspberry Pi Official Magazine 165
We’re all-too accustomed to the feling of being watched on the internet. A search for any product leads to adverts, emails, and goodness knows how many bots tracking you. It feels weird and intrusive, and we aren’t being paranoid – they really are watching us. Luckily you don’t have to reply on online services that […]
Read more →
Win one of three Raspberry Pi 4 with 3GB RAM!
Raspberry Pi 4 is still a powerful piece of kit, and this new 3GB version is great for projects and builds that need slightly more than 2GB of RAM but don’t quite need 4GB. We have three to give away and you can enter below. Win 1 of 3 Raspberry Pi 4 3GB
Read more →
Etch A Sketch CNC machine
The software controlling the Etch A Sketch logs the image, turns it into vectors, turns the vectors into G-code, then sends the G-code to the Etch A Sketch – and it was all written by AI
Read more →