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.