Last Updated: 05/05/2022

PCA685 and LED's

Components >> PCA685 and LED's

PCA9685 and LED's

PCA9685 Board

Usually when you look up PCA9685 boards they are listed as 16-Channel servo drivers.
However, they are also very useful for controlling LED's.

I'm not going to go into a huge amount of detail as a lot of the information is already out there, especially when it comes to driving servos with the board, so if you need more information check out the Adafruit website at

Overview and benefits of using a PCA9685 for LED control

Usually when connecting an LED to an Arduino or ESP32 you require a digital pin and to this you connect the LED along with a resistor. So for 16 LED's you need 16 resistors and 16 pins which means if you are using a Nano or UNO board you are already out of pins.

The PCA9685 can control up to 16 LED's using just 2 pins as it uses I2C as it's control system. This means each individual LED can be controlled independently on 2 pins and as a bonus you don't need any resistors so your wiring is simplified.

As an added bonus, because the PCA8695 uses I2C, each PCA9695 board can have it's own address so you could connect up to 62 PCA9685 boards to the same 2 pins and independently control 992 LED's.

When it comes to controlling the LED, because the PCA9685 is a PWM controller, it can do far more than just turn the LED "on" or "off". With PWM you can alter the brightness of the LED through a range of 4095 values from "off" to full brightness.

Pinout and wiring diagrams

Pin Out

The pin out of these boards is quite simple.

Pins at either end of the board (enables boards to be daisy chained).

GND: Ground

Output Enable: making this pin high disables all outputs. I do not use this pin in my examples.

SCL: Connects to the SCL pin on your Arduino/ESP32

SDA: Connects to your SDA pin on your Arduino/ESP32

VCC: 3-5V maximum. This powers the various components on the board.

V+: This is the power input for the servos/leds connected to the outputs. This is needed because if you connected 16 servos to your Arduino it will not be able to supply enough power, especially if running of a USB connection.

NOTE: There is a V+ and GND with screw connectors in the centre of the board. This is usually the best way to feed external power into the board as it as polarity protection. The V+ on the end of the board does not. YOU HAVE BEEN WARNED.

Top of Board

I2C solder Pads Soldering across these pads enables you to change the I2C address of the board that by default is 0x40.

Yellows/Red/Black pins along the bottom.

Yellow LED Positive: This for a servo would be the signal pin, but for an LED is enough to power the LED.

Black LED Negative (GND): LED ground pin.

Red Power supply for Servo: Not used for LED's.

Wiring:for a few common boards

SDA/SCL connections

Arduino UNO: A4 (SDA), A5 (SCL) :

Arduino Mega 2560: 20 (SDA), 21 (SCL) :

ESP32: 21(SDA), 22 (SCL)

For other Arduino boards see:

Connection Test

Once you have connected your board up as shown above check that it can be found.

If you are using an Arduino board go to File>Examples> Wire>I2c_scanner and upload the skecth to your board.

if all goes well your serial Monitor will display something like

I2C device found at address 0x40 !

Once your device has been found it's time to add the LED's


Example 1: PCA9685LEDv1.ino

Click to Download code: PCA9685LEDv1.ino

Very simple sketch that flashes all led's on and off 5 times and then fades them from off to full brightness.

As can be seen from the code, the "Wire" library is used for the I2C interface while the Adafruit PWM Servo Driver Library controls the PCA9685 board.


/*  PCA9685LEDv1
    Very basic sketch to blink an LED and then do a slow increase in brightness for leds on all pins.

    sketch tested on Arduino Uno and ESP32 Dev Module

    For connections and pin outs for ESP32, Arduino UNO and Mega see

//Libraries required
#include "Wire.h"
#include "Adafruit_PWMServoDriver.h"

Adafruit_PWMServoDriver PCA9685 = Adafruit_PWMServoDriver(0x40, Wire);
//2nd board example at address 50
//Adafruit_PWMServoDriver 2ndPCA9685 = Adafruit_PWMServoDriver(0x50, Wire);

void setup() {

  PCA9685.setPWMFreq(1600);  // This is the maximum PWM frequency and suited to LED's

void loop() {
  int q;
  int w;
   //Simple blink style sketch
  for (w = 0; w < 5; w++) {
    for (q = 0; q < 16; q++) {
      PCA9685.setPWM(q, 0, 4095);//Fully On
      //PCA9685.setPWM(q, 0, 1000);// 25% on
 * PCA9685.setPWM(q, 0, 4095);//Fully On
 * q = channel of the PCA9685 marked just above the yellow pin
 * 0 = the part of the cycle we want the LED to turn to leave as 0 if you are a beginner
 * 4095 (out of a value of 0 to 4095 is the point in the cycle you want to turn OFF the led, higher the number the brighter the LED
    for (q = 0; q < 16; q++) {
      PCA9685.setPWM(q, 0, 4096);//fully OFF...setting value to 4096 takes number out of range
     // PCA9685.setPWM(q, 0, 1000);//on at 25% brightness
  //LED's slowly increase in brightness
      PCA9685.setPWM(q, 0, w);//fully OFF

Additional Resource Links

Lesson 4: Using "for loop" to control code 21/07/2021

Adafruit PWM servo library


This site has been designed to be child friendly, this means that comments cannot be added to videos or directly to the site.
To add a comment or ask a question please email the address in this image: and use PCA685 and LED's as a reference.