Hello, I established communication between Arduino and the NXP PCA9955B with I2C. However, I don't manage to toggle the LED0 that is constantly on at low power. Here is the code:
#include <Wire.h>
int ICSlaveAddress =0x69; // NXP PCA9955B ais for VDD GND VDD for R/W=0, or D3 for R/W=1. Configuration for the AD), AD1, AD2 = 11010010
//All addresses needed for the commands to control the leds page 14-16 Datasheet table 7
int MODE1 = 0x00;
int MODE2 = 0x01;
int LEDOUT0 = 0x2;
int GRPPWM = 0x06;
int GRPFREQ = 0x07;
int PWM0 = 0x08;
int ALLCALLADR = 0x43; // all call I2C bus address
int PWMALL = 0x44; // brightness control for all LED
int IREF0 = 0x18; // output current value registers
// The values of the registers are defined at the page of each register
int MODE1val = 0x89; // 10001001 // default mode
int MODE1valcolour = 0xA9; // colour change
int MODE2val = 0x01; // 00000001
int LEDOUT0OFF = 0x00; // 00000000
int LEDOUT0ON = 0x01; // 00000001
int PWM_val = 0x80;
int IREF_val = 0x14;
int ALLCALL_val = 0x70;
// Writes the three bytes, slave address, control register address and data to the SDA line
void write_command(int Regaddress, int data){
Wire.beginTransmission(ICSlaveAddress);
Wire.write(Regaddress); //controlReg
Wire.write((unsigned char)data);
Wire.endTransmission();
}
void setup() {
Wire.begin();
write_command(MODE1,MODE1valcolour);
delay(1000);
write_command(ALLCALLADR,ALLCALL_val);
delay(500);
}
void loop() {
write_command(LEDOUT0,LEDOUT0ON);
delay(500);
write_command(LEDOUT0,LEDOUT0OFF);
delay(500);
// write_command(PWM0,0xFF);
// delay(500);
write_command(IREF0,0xD2);
delay(500);
}
I followed the diagram at page 46 of the datasheet for the connections. What would you advise? If this is correct, I would expect some bad connection on the chip itself. Thank you for your replies !
Hi again, to answer this question, for anyone that has the same problem, I had to enable the IREF registers to have a control gain at the corresponding leds, with the help of the :
write_command(IREFx,0xFF);
or with
write_command(IREFALL,0xFF);
Hi,
Thanks for your example: it is hard to find an example on how to program the registers of the chip.
Is the code now complete with the IREF solution you've found?