Servo driver, PCA9685 16-channel
Sixteen servo pulses from two I2C wires. It wakes up asleep, at 200 Hz.
- 22 pins
- 1 setting
- In 3 projects
- In 1 lesson
The Servo driver, PCA9685 16-channel in brief
What it is, and every setting the properties panel gives it.
The PCA9685 board is the blue breakout with sixteen three-pin servo headers that runs a robot arm from two I2C wires. VCC takes the logic supply, 5 or 3.3 volts, SDA and SCL go to A4 and A5 on an Uno or GPIO 21 and 22 on an ESP32, with 10k pull-ups already on the board, and V+ brings the servos’ own supply. Inside, a 12-bit counter compares each channel’s ON and OFF counts against an exact 25 MHz oscillator, so at 50 Hz one count is about 4.9 microseconds and the Servo library’s 544 to 2400 microsecond window is 111 to 492 counts. Mokxi keeps the traps the register map sets: the chip wakes asleep with every channel off, the prescale can only be written while it sleeps, auto-increment is off out of reset, and outputs change at the end of the transfer. The Adafruit PWM Servo Driver calls are built in at address 0x40. A tutorial that sets the oscillator to 27 MHz gets pulses about 8 percent short here. Real oscillator spread, the external clock and the sub-addresses are not modeled.
- Family
- Clocks and links
- Pins
- 22
- address
- 64
- the I2C address, 0x40 (64) by default. A real board adds its
A0toA5solder jumpers to 0x40; set the same number here and in the sketch.
22 pins
Named as the editor names them, so a wire lands where you expect it.
How to use the PCA9685 servo driver with an Arduino
SDA goes to A4 and SCL to A5, VCC to the Uno’s 5 volts and GND to GND, and V+ to a separate 5 volt supply for the servos with its ground joined. Call pwm.begin() and then pwm.setPWMFreq(50) in setup(); after that, pwm.writeMicroseconds(channel, us) moves a servo with no pulse timing in the sketch at all.
begin() returns false when nothing answers at 0x40, so the example prints a reminder to check SDA, SCL and VCC when it does. The board’s face prints each channel’s pulse width as the chip makes it, which shows at once whether a wrong angle comes from the sketch’s math or from the servo’s window.
On an ESP32 the same sketch runs with SDA on GPIO 21 and SCL on GPIO 22, and the board’s VCC can come from 3.3 volts.
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
void setup() {
pwm.begin();
pwm.setPWMFreq(50);
}
void loop() {
pwm.writeMicroseconds(0, map(90, 0, 180, 544, 2400));
}What is true about the Servo driver, PCA9685 16-channel, here
In its help article’s own words: what the simulation gets right, and where it stops.
Not modeled
The spread of real oscillators, the external clock input, the sub-addresses and the software reset call. The all-call address 0x70 does work.
From PCA9685 16-channel servo driver, in full.
See the Servo driver, PCA9685 16-channel in a project
3 built-in projects use it. Each opens in the editor, already wired.
Where it turns up in a lesson
One lesson places it in its own circuit.
The boards it is shown on
This board has a built-in project with the Servo driver, PCA9685 16-channel in it.
Arduino libraries for the Servo driver, PCA9685 16-channel
Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.
The rest of the bench
Every one of these is drawn and simulated the same way.
Wire up the Servo driver, PCA9685 16-channel
Open the editor and push it into the breadboard. It is free, and it runs on your own machine.