Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use pca9685: Examples, Pinouts, and Specs

Image of pca9685Design with pca9685 in Cirkit Designer

Introduction

The PCA9685 is a 16-channel, 12-bit PWM (Pulse Width Modulation) controller that communicates via the I2C protocol. It is widely used in robotics, automation, and lighting projects due to its ability to control up to 16 independent PWM outputs with high precision. This component is particularly useful for driving servos, LEDs, and other devices requiring PWM signals, while offloading the processing burden from the microcontroller.

Explore Projects Built with pca9685

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Raspberry Pi-Controlled Dual Servo Driver with PCA9685 Interface: A project utilizing pca9685 in a practical application
Raspberry Pi-Controlled Dual Servo Driver with PCA9685 Interface

This circuit controls two servomotors (MG996R and MG995) using a Raspberry Pi 5 and an Adafruit PCA9685 PWM Servo Breakout board. The Raspberry Pi communicates with the PCA9685 via I2C (using GPIO 2 and GPIO 3 for SDA and SCL, respectively) to send PWM signals to the servos. Power distribution is managed through an Adafruit Perma Proto Small Mint board, which connects the 5V and GND from the Raspberry Pi to the PCA9685 and the servos.

Open Project in Cirkit Designer
Image of 8-Channel Servo Controller with Arduino and PCA9685: A project utilizing pca9685 in a practical application
8-Channel Servo Controller with Arduino and PCA9685

This circuit is designed to control multiple servos using an Adafruit PCA9685 PWM Servo Breakout board, which is interfaced with an Arduino UNO microcontroller. The PCA9685 board receives power from a 9V battery and communicates with the Arduino via I2C (SDA/SCL lines). The Arduino is programmed to generate PWM signals through the PCA9685 to independently control the position of each connected servo.

Open Project in Cirkit Designer
Image of Raspberry Pi 5-Controlled Multi-Servo System with Environmental Sensing: A project utilizing pca9685 in a practical application
Raspberry Pi 5-Controlled Multi-Servo System with Environmental Sensing

This circuit is designed to control multiple servos using two Adafruit PCA9685 PWM Servo Breakout boards, which are interfaced with a Raspberry Pi 5. The Raspberry Pi provides power and control signals to the PCA9685 boards, which in turn generate PWM signals to control the position of each servo. Additional sensors, including a DHT11 temperature and humidity sensor and an MKE-S01 ultrasonic distance sensor, are connected to the Raspberry Pi for environmental data acquisition.

Open Project in Cirkit Designer

Common Applications

Technical Specifications

Key Technical Details

Pin Configuration and Descriptions

The PCA9685 has 28 pins. Below is a description of the key pins:

Pin Name Type Description
VCC Power Supply voltage (2.3V to 5.5V).
GND Ground Ground connection.
SDA Input/Output I2C data line.
SCL Input I2C clock line.
OE Input Output enable (active low). Disables all outputs when high.
A0–A5 Input Address pins for configuring the I2C address.
OUT0–OUT15 Output PWM output channels.
EXTCLK Input External clock input (optional).
V+ Power External power supply for driving servos or LEDs (separate from VCC).
RESET Input Resets the device when pulled low.

Usage Instructions

How to Use the PCA9685 in a Circuit

  1. Powering the PCA9685:

    • Connect the VCC pin to a 3.3V or 5V power source.
    • Connect the GND pin to the ground of your circuit.
    • If driving servos or LEDs, connect an external power source to the V+ pin.
  2. I2C Communication:

    • Connect the SDA and SCL pins to the corresponding I2C pins on your microcontroller.
    • Use pull-up resistors (typically 4.7kΩ) on the SDA and SCL lines if not already present.
  3. Configuring the I2C Address:

    • Set the address pins (A0–A5) to either HIGH or LOW to configure the I2C address.
    • The default address is 0x40 when all address pins are LOW.
  4. Connecting Outputs:

    • Connect servos, LEDs, or other devices to the OUT0–OUT15 pins.
    • Ensure the total current draw does not exceed the PCA9685's limits.
  5. Programming the PCA9685:

    • Use an I2C library to communicate with the PCA9685.
    • Set the PWM frequency and duty cycle for each channel as needed.

Example Code for Arduino UNO

Below is an example of how to control servos using the PCA9685 with an Arduino UNO:

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

// Create an instance of the PCA9685 driver
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

void setup() {
  // Initialize serial communication for debugging
  Serial.begin(9600);
  Serial.println("Initializing PCA9685...");

  // Initialize the PCA9685
  pwm.begin();
  pwm.setPWMFreq(50); // Set PWM frequency to 50 Hz for servos
}

void loop() {
  // Example: Move a servo connected to channel 0
  int servoMin = 150; // Minimum pulse length (adjust for your servo)
  int servoMax = 600; // Maximum pulse length (adjust for your servo)

  // Sweep the servo from minimum to maximum position
  for (int pulse = servoMin; pulse <= servoMax; pulse++) {
    pwm.setPWM(0, 0, pulse); // Channel 0, start at 0, pulse width
    delay(10); // Small delay for smooth movement
  }

  // Sweep the servo back to the minimum position
  for (int pulse = servoMax; pulse >= servoMin; pulse--) {
    pwm.setPWM(0, 0, pulse);
    delay(10);
  }
}

Important Considerations

Troubleshooting and FAQs

Common Issues and Solutions

  1. No Response from the PCA9685:

    • Verify the I2C connections (SDA, SCL) and ensure pull-up resistors are present.
    • Check the I2C address configuration and ensure it matches your code.
  2. Servos or LEDs Not Working:

    • Ensure the external power supply (V+) is connected and sufficient for your devices.
    • Verify the PWM frequency and pulse width settings in your code.
  3. Flickering LEDs or Erratic Servo Movement:

    • Add decoupling capacitors near the V+ pin to stabilize the power supply.
    • Check for loose or poor connections in the circuit.
  4. Overheating:

    • Ensure the total current draw does not exceed the PCA9685's limits.
    • Use a heatsink or active cooling if necessary.

FAQs