Driver for the PCA9685 PWM control IC. Its commonly used to control servos, leds and motors.

See also

The Adafruit CircuitPython Motor library can be used to control the PWM outputs for specific uses instead of generic duty_cycle adjustments.

  • Author(s): Scott Shawcroft

Implementation Notes


Software and Dependencies:

class adafruit_pca9685.PCA9685(i2c_bus: I2C, *, address: int = 64, reference_clock_speed: int = 25000000)[source]

Initialise the PCA9685 chip at address on i2c_bus.

The internal reference clock is 25mhz but may vary slightly with environmental conditions and manufacturing variances. Providing a more precise reference_clock_speed can improve the accuracy of the frequency and duty_cycle computations. See the example for how to derive this value by measuring the resulting pulse widths.

  • i2c_bus (I2C) – The I2C bus which the PCA9685 is connected to.

  • address (int) – The I2C address of the PCA9685.

  • reference_clock_speed (int) – The frequency of the internal reference clock in Hertz.


Sequence of 16 PWMChannel objects. One for each channel.

deinit() None[source]

Stop using the pca9685.

property frequency: float

The overall PWM frequency in Hertz.


The reference clock speed in Hz.

reset() None[source]

Reset the chip.

class adafruit_pca9685.PCAChannels(pca: PCA9685)[source]

Lazily creates and caches channel objects as needed. Treat it like a sequence.


pca (PCA9685) – The PCA9685 object

class adafruit_pca9685.PWMChannel(pca: PCA9685, index: int)[source]

A single PCA9685 channel that matches the PWMOut API.

  • pca (PCA9685) – The PCA9685 object

  • index (int) – The index of the channel

property duty_cycle: int

16 bit value that dictates how much of one cycle is high (1) versus low (0). 0xffff will always be high, 0 will always be low and 0x7fff will be half high and then half low.

property frequency: float

The overall PWM frequency in Hertz (read-only). A PWMChannel’s frequency cannot be set individually. All channels share a common frequency, set by PCA9685.frequency.