Besides the Adafruit CircuitPython ServoKit library, the board also works with the Adafruit_CircuitPython_PCA9685 library.
Documentation for the library is on Read the Docs here.
Besides the introduction there are examples and a reference to the API (functions) available.
The code is on GitHub.
Example
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT # Outputs a 50% duty cycle PWM single on the 0th channel. # Connect an LED and resistor in series to the pin # to visualize duty cycle changes and its impact on brightness. import board from adafruit_pca9685 import PCA9685 # Create the I2C bus interface. i2c = board.I2C() # uses board.SCL and board.SDA # i2c = busio.I2C(board.GP1, board.GP0) # Pi Pico RP2040 # Create a simple PCA9685 class instance. pca = PCA9685(i2c) # Set the PWM frequency to 60hz. pca.frequency = 60 # Set the PWM duty cycle for channel zero to 50%. duty_cycle is 16 bits to match other PWM objects # but the PCA9685 will only actually give 12 bits of resolution. pca.channels[0].duty_cycle = 0x7FFF
Page last edited July 29, 2025
Text editor powered by tinymce.