Pan-Tilt HAT review
By Russell Barnes. Posted
A Raspberry Pi camera stand with horizontal and vertical motion servos
Advertisement
Christmas is coming – keep Santa on the right track with our Raspberry Pi gift guide!
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
Meet Phil Hutchinson: element14 community organiser
“I come from a background of always being the ‘technical guy’ in every role,” Phil says. “I was the tech for a community radio station, the technician on a paintball site, technical manager of a chain of live venues. Lots of scrappy startups. Every role needed something fixing, and I am that guy.” When did […]
Read more →
M314 Alien Motion Tracker
Game over, man. Game over. It’s the ultimate tracker from Aliens.
Read more →
Christmas Gift Guide in Raspberry Pi Official Magazine 160
There’s a ton of great stuff in issue 160, including the incredible motion scanner, inspired by the film Aliens. It’s beautiful, it uses Raspberry Pi technology and makes a satisfying ping sound, and the best thing about it is that it actually works, thanks to a DreamHAT+ radar board. Yes, you too can join the […]
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.