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 Pulse Width Modulation (PWM) controller that communicates via the I2C protocol. It is widely used in robotics, automation, and lighting projects due to its ability to control multiple servos or LEDs with high precision. The PCA9685 offloads the PWM generation task from the microcontroller, freeing up resources for other operations.

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 ESP32-Controlled Servo Motor with PCA9685 PWM Interface: A project utilizing PCA9685 in a practical application
ESP32-Controlled Servo Motor with PCA9685 PWM Interface

This circuit features an ESP32 microcontroller connected to an Adafruit PCA9685 PWM Servo Breakout board for controlling servos with pulse-width modulation (PWM). The ESP32 communicates with the PCA9685 via I2C (using pins D21 and D22 for SDA and SCL, respectively). Power is supplied by a 12V battery, which is stepped down to 5V by a converter to power the ESP32, the PCA9685, and a connected servo motor.

Open Project in Cirkit Designer

Common Applications

Technical Specifications

Pin Configuration

The PCA9685 is typically available in a 28-pin package. Below is the pin configuration:

Pin Name Description
1-16 PWM0-PWM15 16 PWM output channels for controlling servos or LEDs
17 VCC Power supply input (2.3V to 5.5V)
18 GND Ground
19 SDA I2C data line
20 SCL I2C clock line
21-26 A0-A5 Address pins for setting the I2C address (allows up to 62 devices on one bus)
27 OE Output enable (active low, can disable all outputs when pulled high)
28 V+ External power supply for driving servos or LEDs (up to 6V)

Usage Instructions

Connecting the PCA9685

  1. Power Supply: Connect the VCC pin to a 3.3V or 5V power source, and the GND pin to ground. If driving servos or LEDs, connect an external power supply 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. Address Configuration: Set the I2C address using the A0-A5 pins. Leave them floating or connect them to GND/VCC to configure the address.

Example: Using PCA9685 with Arduino UNO

Below is an example of how to control a servo motor using the PCA9685 and Arduino UNO:

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

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

#define SERVO_MIN 150 // Minimum pulse length for the servo (in 12-bit units)
#define SERVO_MAX 600 // Maximum pulse length for the servo (in 12-bit units)

void setup() {
  Serial.begin(9600); // Initialize serial communication for debugging
  pwm.begin();        // Initialize the PCA9685
  pwm.setPWMFreq(50); // Set PWM frequency to 50 Hz (standard for servos)
}

void loop() {
  // Sweep the servo from 0° to 180°
  for (int pulse = SERVO_MIN; pulse <= SERVO_MAX; pulse++) {
    pwm.setPWM(0, 0, pulse); // Set PWM on channel 0
    delay(10);               // Small delay for smooth movement
  }

  // Sweep the servo back from 180° to 0°
  for (int pulse = SERVO_MAX; pulse >= SERVO_MIN; pulse--) {
    pwm.setPWM(0, 0, pulse); // Set PWM on channel 0
    delay(10);               // Small delay for smooth movement
  }
}

Best Practices

Troubleshooting and FAQs

Common Issues

  1. No Response from PCA9685

    • Cause: Incorrect I2C address or wiring.
    • Solution: Verify the I2C address and ensure SDA/SCL connections are correct.
  2. Servos or LEDs Not Functioning

    • Cause: Insufficient power supply or incorrect PWM settings.
    • Solution: Check the external power supply connected to the V+ pin. Ensure the PWM frequency and pulse width are configured correctly.
  3. Flickering LEDs

    • Cause: Unstable power supply or incorrect frequency.
    • Solution: Add a decoupling capacitor and verify the PWM frequency.

FAQs

  1. Can I use the PCA9685 with a 3.3V microcontroller?

    • Yes, the PCA9685 is compatible with both 3.3V and 5V logic levels.
  2. How many PCA9685 modules can I connect to a single I2C bus?

    • Up to 62 modules can be connected by configuring the A0-A5 address pins.
  3. What is the maximum current the PCA9685 can handle?

    • Each channel can sink up to 25 mA or source up to 10 mA. For higher currents, use external transistors or MOSFETs.

By following this documentation, you can effectively integrate the PCA9685 into your projects for precise PWM control.