Library for interfacing NXP PCA9685 16-channel, 12-bit PWM controller for LED/SERVO/etc.
The PCA9685 is an I²C-bus controlled 16-channel LED controller optimized for Red/Green/Blue/Amber (RGBA) color backlighting applications. -) I2C interface with communication speed up to 1 MHz (I2C Fast Mode Plus) -) Six hardware address pins allow up to 62 devices on the same bus -) 4096 steps (12-bit PWM) of individual PWM (e.g. LED brightness) control
typical I2C clock speed to be used (400kHz, I2C Fast-Mode)
Available PCA9685 I2C addresses
MODE1 configuration bits
This bit is a ‘sticky bit’, that is, it cannot be cleared by writing a logic 0 to it. The EXTCLK bit can only be cleared by a power cycle or software reset. EXTCLK range is DC to 50 MHz.
MODE2 configuration bits
Specifies which unit is used for the "unit" parameter of the "PCA9685_SetPWM()" function.
Initializes I2c communication with the PCA9685 and prepares the PCA9685 for use
Reads mode register 1 and 2 from the PCA9685 and stores the content of these registers in the transferred, empty device handle for a PCA9685. In addition, the default PWM frequency (f=200Hz, T=5ms) is also stored in the transferred, empty device handle.
Activates the PCA9685 by setting the "MODE1" and "MODE2" register
Sets PWM frequency at which all outputs modulate.
Since the "PRE_SCALE" register can only be set when sleep mode is active, the following sequence is executed:
Sets PWM output i.e. controls turn-on time and duty cycle for a specific PWM output.
Sets the PCA9685 into sleep mode (i.e. Oscillator is off) and thus grants minimum power consumption
The sleep mode is activated by setting the "SLEEP" bit. All other bits retain the state determined when PCA9685_Init() was called.
absolute maximum I2C clock speed (1MHz, I2C Fast-Mode Plus)
PCA9685 Register Addresses (Address | Default | Description)
Reads the contents of a register from the PCA9685
Writes the transferred data into the desired register of the PCA9685
Executes an I2C communication with the PCA9685. Data is first of all sent and data is then received.
Performs a reset of the PCA9685 using the "General Call" command through the I2C-bus, identical to the Power-On Reset (POR) that initializes the registers to their default state causing the outputs to be set LOW.