Setting Up and Using the Adafruit 16-Channel Servo HAT for Raspberry Pi

I’ve just finished the newest tutorial “Setting Up and Using the Adafruit 16-Channel Servo HAT for Raspberry Pi

This guide will teach you how to control up to 992 5V Servos through the GPIO pins on your Raspberry Pi! But more practically, without stacking multiple HATS (Hardware Attached on Top), this guide will teach exactly how to control sixteen 5V servos using a single Raspberry Pi single-board computer. This is all possible via the Adafruit Servo HAT which will act as a PWM expander, taking up only 2 GPIO pins and communicating through I2C.

The setup created in this guide will be able to send out 16 unique PWM signals. PWM signals are great for servos (both standard and continuous) and can be used for a myriad of other purposes (like LED light control, motor speed, and even the heat output of a heater).

Read more

3 Likes

Hi Tim, I am wondering that instead of using Adafruit 16-Channel PWM / Servo HAT for Raspberry Pi - Mini Kit, can I use another servo driver which is the PCA9685 and go with the same of your code and method/process that you have made to control multiple servos?

looking forward to your advice ^^

love your work man!!

3 Likes

Hey mate, big thanks :slight_smile: and if you use that PCA9685 I reckon the majority if not all the code will be exactly the same. Both hats have very similar ICs, chips on board and both are speaking through the same I2C communication. Here is a guide on that particular PCA9685 and configuring it for a Raspberry Pi - Configuring Your Pi for I2C | Adafruit 16 Channel Servo Driver with Raspberry Pi | Adafruit Learning System

Hope this helps!

3 Likes

Hey Tim, thank you heaps mate!!! And I have got one more question, can the servo run in parallel? I mean I’ve to run 4 servos at the same time to open and close my eyelid mechanism(blink or twinkle). If it can, could you please beat me a little bit about that. Sorry man, I am a beginner.

Thank you in advance.

2 Likes

Hi Mike,

Absolutely! The PCA9685 chip that powers this HAT handles sending the PWM “target position” to the servos, and the Pi is free to go off and do something else (like tell the next servo to start moving). This all happens in the uS scale, so you’ll almost certainly be able to get things moving at the same time.

Let us know if you have more questions :slight_smile:
-James

3 Likes

I am trying to use the servo hat but am stuck on installing python-smbus. I am getting an error that python-smbus has no installation candidate. Its a new Pi with all the latest so I am guessing python-smbus is not compatible?

Brett

2 Likes

Hi Brett,

A lot of things haven’t made it over to the new “Bullseye” Pi OS. I’d see if you can install the older “Buster” OS and see if you get a candidate there.

A pain I know, but it’s just the way software compatibility goes when a new version of something comes out.

-James

2 Likes

I’m trying to get this working with a pi 4. Works on my pi zero, but not pi 4, here’s the details:

Any ideas?

python3-smbus may work.

1 Like