The Adafruit PCA9685 PWM Servo Breakout is a versatile and user-friendly breakout board based on the PCA9685 PWM driver IC. It enables the control of up to 16 servos or PWM outputs through just two pins (SDA and SCL) from a microcontroller, such as an Arduino UNO. This component is ideal for robotics, animatronics, lighting control, and any application requiring multiple PWM outputs. It supports both 3.3V and 5V logic levels, making it compatible with a wide range of microcontrollers.
Pin Number | Pin Name | Description |
---|---|---|
1 | VCC | Power supply for the PCA9685 and servo motors (5-6V) |
2 | GND | Ground connection |
3 | SDA | I2C data line |
4 | SCL | I2C clock line |
5-20 | PWM0-15 | PWM output channels for servos or LEDs |
21 | OE | Output enable (active low) |
22 | EXTCLK | External clock input (optional) |
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
// Called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
void setup() {
Serial.begin(9600);
Serial.println("16 channel PWM test!");
pwm.begin();
pwm.setPWMFreq(60); // Analog servos run at ~60 Hz updates
delay(10);
}
void loop() {
// Sweep all servos back and forth
for (uint16_t pulselen = SERVOMIN; pulselen < SERVOMAX; pulselen++) {
for (uint8_t i = 0; i < 16; i++) {
pwm.setPWM(i, 0, pulselen);
}
}
delay(500);
for (uint16_t pulselen = SERVOMAX; pulselen > SERVOMIN; pulselen--) {
for (uint8_t i = 0; i < 16; i++) {
pwm.setPWM(i, 0, pulselen);
}
}
delay(500);
}
Note: Before using the above code, define SERVOMIN
and SERVOMAX
according to the specifications of the servos you are using.
SERVOMIN
and SERVOMAX
values to match the servo's specifications.Q: Can I chain multiple PCA9685 boards together? A: Yes, you can connect multiple boards to the same I2C bus by setting a unique address for each board using the address jumpers.
Q: What is the maximum number of servos I can control with one PCA9685 board? A: You can control up to 16 servos per board.
Q: Can I use this board with a Raspberry Pi or other single-board computers? A: Yes, the PCA9685 is compatible with any microcontroller or single-board computer that supports I2C communication.
Q: How do I set a specific PWM frequency?
A: Use the setPWMFreq()
function in your code to set the desired frequency. The frequency range is 40Hz to 1000Hz.