Part

Servo driver, PCA9685 16-channel

Sixteen servo pulses from two I2C wires. It wakes up asleep, at 200 Hz.

See every part
  • 22 pins
  • 1 setting
  • In 3 projects
  • In 1 lesson
Drawn live by the editor's own code, at the size you see it.
At a glance

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 A0 to A5 solder jumpers to 0x40; set the same number here and in the sketch.
Pins

22 pins

Named as the editor names them, so a wire lands where you expect it.

Pin
What it does
GND
Ground, shared with the board and the servo supply.
OE
Output enable, active low. Pulled low on the board: leave it unwired.
SCL
The I2C bus. The board has 10k pull-ups on both.
SDA
The I2C bus. The board has 10k pull-ups on both.
VCC
The chip's logic supply, 2.3 V to 5.5 V: the board's 5 V or 3.3 V.
V+
The servos' supply, from its own 5 V source. The chip does not use it.
PWM0
PWM1
PWM2
PWM3
PWM4
PWM5
PWM6
PWM7
PWM8
PWM9
PWM10
PWM11
PWM12
PWM13
PWM14
PWM15
How to use 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.

Part pin
Board pin
SDA
A4
SCL
A5
VCC
5 V
GND
GND
V+
Separate 5 V supply
PWM0 to PWM3
The arm’s four servos

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.

Arduino Uno: pick and place armlive0.000 s 0.00x
Click to open it in the editor
This is the simulator itself, running here. Click anything to open it in the editor.
One servo on channel 0
#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));
}
How it is modeled

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.

Projects

See the Servo driver, PCA9685 16-channel in a project

3 built-in projects use it. Each opens in the editor, already wired.

Lessons

Where it turns up in a lesson

One lesson places it in its own circuit.

Boards

The boards it is shown on

This board has a built-in project with the Servo driver, PCA9685 16-channel in it.

Libraries

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.

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.