PCA9685 driver for RGB LEDs

Introduction

The PCA9685 driver for RGB LEDs is used in conjunction with an RGB LED either in common cathode or common anode layout.


Driver Parameters

The PCA9685 driver for RGB LEDs has five parameters that need to be configured:

I2C Address

This is the address the device is being referenced by on the I2C bus. The base I2C address is

  • Binary: 1000000

  • Hex: 0x40

The last 6 bits are altered by the address A0-A5 pins:

A5 A4 A3 A2 A1 A0

1 0 0 0 0 0 0

So as an example if we set all pins to 1 we have

  • Binary: 1111111

  • Hex: 0x7f

The device has a “can all“ address, which is 0x70, so the I2C scan is going to report two addresses usually: the one selected with the A pins and 0x70.

More information about addressing can be found in the datasheet

Also for translation help see the Binary to Hex converter here

Red Channel

This channel is connected to the red leg of the LED.

Green Channel

This channel is connected to the green leg of the LED.

Blue Channel

This channel is connected to the blue leg of the LED.

Layout

This determines whether the common connection of the LED is connected to GND (common cathode) or 3.3V (common anode).


Wiring

The PCA9685 can be found in either a DIP socket adapter or in popular development boards as shown below

Development Board

 

Chip Pinout

Example

The PCA9685 is connected to 5V and GND from the circuit and to the Builder Base via I2C with the SDA pins connected to each other and the SCL pins connected to each other. Three output channels of the PCA are connected to the color legs of the LED and the common cathode of the LED is connected to GND.

Breadboard 

Schematic 

Used Pins

Used Pins

Description

Used Pins

Description

 5V

The voltage level for the assembly

GND

The ground potential for the assembly

SDA

The I2C data line

SCL

The I2C clock line


How to write an App

Navigate to the App Builder and create a new application. You can find the “LED RGB” code object under the “Hardware” Tab in the object drop down menu on the left, or you can also use the search bar.

 

 

 

 

 

Drag the “LED RGB” object onto the canvas.

 

 Next, located under the interface tab find the “Color Picker” object and drag it onto the canvas.

 

 

 

Finally, connect the Color port from the “Color Picker” object to the RGB Color port on the “LED RGB” object, label your objects, and save your application.


How to create a firmware

Navigate to the Firmware Builder and create a new firmware file.

Click the “+ Add Hardware” button which will open a modal window. Scroll down in the list to find the “Display” section and select the “LED RGB” hardware option.

Give your device a name, and click “Add Hardware”

 

 

 

Next, select the “LED RGB” driver under the driver dropdown menu.

 

 

 

For this example we select:

I2C Address: 0x40

Red Pin: 0

Green Pin: 1

Blue Pin: 2

Layout: Common Cathode

 

You may now save your firmware file and upload it to one of your clients.

 

 

 


Supported Hardware

  • RGB LED

  • PCA9685

 


Downloads

Apps

Firmware

Assets