RGB led strips flicker with PCA9685

Hi guys,
l am quite a newbie to arduino and lately I have been messing around with SMD5050 rgb strips for my balcony fence. I have used exactly 13 strips, each strip being 0.3 m long. To control all the channels I used 3 PCA9685 chained and connected to 13 uln2003a IC and each strip was wired as follows:


previous problems I encountered were discussed in the following topics:

But due to all the help of the people in this forum I was able to solve them, So I really do appreciate it!

But I have tried to implement a fade animations for all the strips at once using the following code:

#include "Wire.h"
#include "Adafruit_PWMServoDriver.h"

int r, g, b;
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40, Wire);
Adafruit_PWMServoDriver pwm1 = Adafruit_PWMServoDriver(0x41, Wire);
Adafruit_PWMServoDriver pwm2 = Adafruit_PWMServoDriver(0x42, Wire);
void setup() {

  Wire.begin();
  pwm.begin();
  pwm.setPWMFreq(500);
  pwm1.begin();
  pwm1.setPWMFreq(500);
  pwm2.begin();
  pwm2.setPWMFreq(500);  
}

void colorFading(int F_DELAY) {
  for (r = 0; r < 4095; r+=1) {
  pwm.setPWM(0, 0, r);
  pwm.setPWM(3, 0, r);
  pwm.setPWM(6, 0, r);
  pwm.setPWM(9, 0, r);
  pwm.setPWM(12, 0, r);
  pwm.setPWM(15, 0, r);
  pwm1.setPWM(2, 0, r);
  pwm1.setPWM(5, 0, r);
  pwm1.setPWM(8, 0, r);
  pwm1.setPWM(11, 0, r);
  pwm1.setPWM(14, 0, r);
  pwm2.setPWM(1, 0, r);
  pwm2.setPWM(4, 0, r);
  }
  delay(F_DELAY);
  for (b = 4095; b > 0; b-=1) {
  pwm.setPWM(2, 0, b);
  pwm.setPWM(5, 0, b);
  pwm.setPWM(8, 0, b);
  pwm.setPWM(11, 0, b);
  pwm.setPWM(14, 0, b);
  pwm1.setPWM(1, 0, b);
  pwm1.setPWM(4, 0, b);
  pwm1.setPWM(7, 0, b);
  pwm1.setPWM(10, 0, b);
  pwm1.setPWM(13, 0, b);
  pwm2.setPWM(0, 0, b);
  pwm2.setPWM(3, 0, b);
  pwm2.setPWM(6, 0, b);
  
  }
  delay(F_DELAY);
  for (g = 0; g < 4095; g+=1) {
  pwm.setPWM(1, 0, g);
  pwm.setPWM(4, 0, g);
  pwm.setPWM(7, 0, g);
  pwm.setPWM(10, 0, g);
  pwm.setPWM(13, 0, g);
  pwm1.setPWM(0, 0, g);
  pwm1.setPWM(3, 0, g);
  pwm1.setPWM(6, 0, g);
  pwm1.setPWM(9, 0, g);
  pwm1.setPWM(12, 0, g);
  pwm1.setPWM(15, 0, g);
  pwm2.setPWM(2, 0, g);
  pwm2.setPWM(5, 0, g);
  }
  delay(F_DELAY);
  for (r = 4095; r > 0; r-=1) {
  pwm.setPWM(0, 0, r);
  pwm.setPWM(3, 0, r);
  pwm.setPWM(6, 0, r);
  pwm.setPWM(9, 0, r);
  pwm.setPWM(12, 0, r);
  pwm.setPWM(15, 0, r);
  pwm1.setPWM(2, 0, r);
  pwm1.setPWM(5, 0, r);
  pwm1.setPWM(8, 0, r);
  pwm1.setPWM(11, 0, r);
  pwm1.setPWM(14, 0, r);
  pwm2.setPWM(1, 0, r);
  pwm2.setPWM(4, 0, r);
  }
  delay(F_DELAY);
  for (b = 0; b < 4095; b+=1) {
  pwm.setPWM(2, 0, b);
  pwm.setPWM(5, 0, b);
  pwm.setPWM(8, 0, b);
  pwm.setPWM(11, 0, b);
  pwm.setPWM(14, 0, b);
  pwm1.setPWM(1, 0, b);
  pwm1.setPWM(4, 0, b);
  pwm1.setPWM(7, 0, b);
  pwm1.setPWM(10, 0, b);
  pwm1.setPWM(13, 0, b);
  pwm2.setPWM(0, 0, b);
  pwm2.setPWM(3, 0, b);
  pwm2.setPWM(6, 0, b);
  }
  delay(F_DELAY);
  for (g = 4095; g > 0; g-=1) {
  pwm.setPWM(1, 0, g);
  pwm.setPWM(4, 0, g);
  pwm.setPWM(7, 0, g);
  pwm.setPWM(10, 0, g);
  pwm.setPWM(13, 0, g);
  pwm1.setPWM(0, 0, g);
  pwm1.setPWM(3, 0, g);
  pwm1.setPWM(6, 0, g);
  pwm1.setPWM(9, 0, g);
  pwm1.setPWM(12, 0, g);
  pwm1.setPWM(15, 0, g);
  pwm2.setPWM(2, 0, g);
  pwm2.setPWM(5, 0, g);
  }
  delay(F_DELAY);
}
void loop() {
 colorFading(10);

}

The animations seem smooth but the problem is that when the fade happens the strips flicker and this is specially visible in the last few led strips connected to the third PCA9685 board. If anyone has their ideas, I would appreciate you guys very much if you can share them.

This has surely been suggested in one or more of your other topics on your project, but have you tried providing power to both ends of your LED strips rather than just at one end ?

hi Mr. UKHeliBob. thanks for the response but how will that help this problem

Power sags as it travels down a conductor (conductors have resistance, reducing the voltage, V = IR). "Injecting" power at multiple locations along the LED strip allows the LEDs to have full VCC rather than the sagging voltage.

But I do not think that really this is the problem since it works just fine when fading effect is not used or when fading effect is only used on one or two channels without using it on all chanels...

Why not? Why do you think resistance is not present in every wire?

How many LEDs are involved? How many in each channel? What is the size of the power supply?

PWM is "flickering".... and if you add resistance, the LEDs going OFF to ON to OFF will show that flickering.

An LED with increased resistance is "faded"

The PCA9685 has 200 ohm resistors on the signal outputs. Maybe that has an effect.

Ah ok thanks for the clarification. Well I am using smd5050 nonaddressable dumb rgb led strips and as the power supply I am using a 12v car battery.

Hi Mr SurferTim, thanks for the response. Yes this can also be the problem.

Monochrome LED strips still have resistance in their wires.

Do you think this can be a the problem as well. Maybe I should use the library these peopl use and try it out.

I do not know. Give it a try.

#include "PCA9685.h"

PCA9685 pwmController1(B000000);        // Library using B000000 (A5-A0) i2c address, and default Wire @400kHz
PCA9685 pwmController2(B000001);        // Library using B000001 (A5-A0) i2c address, and default Wire @400kHz

// Not a real device, will act as a proxy to pwmController1 and pwmController2, using all-call i2c address 0xE0, and default Wire @400kHz
PCA9685 pwmControllerAll(PCA9685_I2C_DEF_ALLCALL_PROXYADR);

void setup() {
    Serial.begin(115200);               // Begin Serial and Wire interfaces
    Wire.begin();

    pwmControllerAll.resetDevices();    // Resets all PCA9685 devices on i2c line

    pwmController1.init();              // Initializes first module using default totem-pole driver mode, and default disabled phase balancer
    pwmController2.init();              // Initializes second module using default totem-pole driver mode, and default disabled phase balancer

    pwmControllerAll.initAsProxyAddresser(); // Initializes 'fake' module as all-call proxy addresser

    // Enables all-call support to module from 'fake' all-call proxy addresser
    pwmController1.enableAllCallAddress(pwmControllerAll.getI2CAddress());
    pwmController2.enableAllCallAddress(pwmControllerAll.getI2CAddress()); // On both

    pwmController1.setChannelOff(0);    // Turn channel 0 off
    pwmController2.setChannelOff(0);    // On both

    pwmControllerAll.setChannelPWM(0, 4096); // Enables full on on both pwmController1 and pwmController2

    Serial.println(pwmController1.getChannelPWM(0)); // Should output 4096
    Serial.println(pwmController2.getChannelPWM(0)); // Should also output 4096

    // Note: Various parts of functionality of the proxy class instance are actually
    // disabled - typically anything that involves a read command being issued.
}

void loop() {
}

guys I wrote this code to test out some other abilities of this library but it does not out 4096 and 4096 in serial monitor.

It is 12 bit resolution. That is 0 to 4095. 4096 is the 13th bit.

I tried putting 4095 aswell but still does not work.

I've seen this before. Try setting an int variable to 0 and 4095 and use the variable in the calls. It had problems using a literal number. Don't know why.

Ok let me try, can you confirm my idea about what this program does btw by explaining what it does to me.

I was thinking it will set the given value to channel 0 in all boards.

Which program ?