PaulRB:
Is usual to connect pin 9 of the ULN to the same power rail as used by the loads (yellow wire in your diagram). This important for reactive loads like relays, not really important for LEDs, but it wouldn't do any harm. If you did that, you could connect the caps across pins 8 & 9. Don't pin your hopes on this fixing the flickering, but worth a try.
If that doesn't help, I would look next at the power supply. What happens if you remove the Arduino and the ULNs and wire up the LED strips direct to the PSU?
Another thing to try would be to make a very simple sketch that does not use PWM, just sets the outputs connected to the ULN inputs to OUTPUT & HIGH. If that does not flicker, post your PWM sketch for review.
Okay, tried it - didn't work. Here's my code. May look a bit messy, I didn't finish it up yet. It converts RGB to HSV and back so I can set the color by setting the H value. Th function colorShift is called in loop which sets the color.
#define SIZE 255
#define DELAY 100
#define HUE_MAX 6.0
#define HUE_DELTA 0.01
//LED PINs
const int red1 = 2;
const int green1 = 3;
const int blue1 = 4;
const int red2 = 5;
const int green2 = 6;
const int blue2 = 7;
const int red3 = 8;
const int green3 = 9;
const int blue3 = 10;
const int red4 = 11;
const int green4 = 12;
const int blue4 = 13;
//Values needed for HSV
long rgb[3];
long rgbval, temp_value, rands;
float hue=0.0, saturation=1, value=1;
long bright[3] = { 107, 67, 256};
int memory = 0;
int strip = 1;
void setup() {
// Initialize LEDs - code reworked. Once was a single Loop.
pinMode(red1, OUTPUT);
pinMode(red2, OUTPUT);
pinMode(red3, OUTPUT);
pinMode(red4, OUTPUT);
pinMode(green1, OUTPUT);
pinMode(green2, OUTPUT);
pinMode(green3, OUTPUT);
pinMode(green4, OUTPUT);
pinMode(blue1, OUTPUT);
pinMode(blue2, OUTPUT);
pinMode(blue3, OUTPUT);
pinMode(blue4, OUTPUT);
analogWrite(red1, 0);
analogWrite(red2, 0);
analogWrite(red3, 0);
analogWrite(red4, 0);
analogWrite(green1, 0);
analogWrite(green3, 0);
analogWrite(green2, 0);
analogWrite(green4, 0);
analogWrite(blue1, 0);
analogWrite(blue2, 0);
analogWrite(blue3, 0);
analogWrite(blue4, 0);
}
void loop() {
//changes color over time.
colorShift();
}
//called from Loop function
void colorShift(){
hue += HUE_DELTA;
//switch to zero
if (hue > HUE_MAX) {
hue=0.0;
}
//write color
setLEDs(hue, saturation, value);
delay(20);
}
//Turns on all LEDs with value
void setLEDs(float hue, float saturation, float value){
rgbval=HSV_to_RGB(hue, saturation, value);
rgb[0] = (rgbval & 0x00FF0000) >> 16; // there must be better ways
rgb[1] = (rgbval & 0x0000FF00) >> 8;
rgb[2] = rgbval & 0x000000FF;
//rewritten -- once was a single loop
analogWrite(red1, rgb[0] * bright[0]/256);
analogWrite(red2, rgb[0] * bright[0]/256);
analogWrite(red3, rgb[0] * bright[0]/256);
analogWrite(red4, rgb[0] * bright[0]/256);
analogWrite(green1, rgb[1] * bright[1]/256);
analogWrite(green2, rgb[1] * bright[1]/256);
analogWrite(green3, rgb[1] * bright[1]/256);
analogWrite(green4, rgb[1] * bright[1]/256);
analogWrite(blue1, rgb[2] * bright[2]/256);
analogWrite(blue2, rgb[2] * bright[2]/256);
analogWrite(blue3, rgb[2] * bright[2]/256);
analogWrite(blue4, rgb[2] * bright[2]/256);
}
//Converts HSV to RGB
long HSV_to_RGB( float h, float s, float v ) {
// H is given on [0, 6]. S and V are given on [0, 1].
// RGB is returned as a 24-bit long #rrggbb
int i;
float m, n, f;
// not very elegant way of dealing with out of range: return black
if ((s<0.0) || (s>1.0) || (v<0.0) || (v>1.0)) {
return 0L;
}
if ((h < 0.0) || (h > 6.0)) {
return long( v * 255 ) + long( v * 255 ) * 256 + long( v * 255 ) * 65536;
}
i = floor(h);
f = h - i;
if ( !(i&1) ) {
f = 1 - f; // if i is even
}
m = v * (1 - s);
n = v * (1 - s * f);
switch (i) {
case 6:
case 0:
return long(v * 255 ) * 65536 + long( n * 255 ) * 256 + long( m * 255);
case 1:
return long(n * 255 ) * 65536 + long( v * 255 ) * 256 + long( m * 255);
case 2:
return long(m * 255 ) * 65536 + long( v * 255 ) * 256 + long( n * 255);
case 3:
return long(m * 255 ) * 65536 + long( n * 255 ) * 256 + long( v * 255);
case 4:
return long(n * 255 ) * 65536 + long( m * 255 ) * 256 + long( v * 255);
case 5:
return long(v * 255 ) * 65536 + long( m * 255 ) * 256 + long( n * 255);
}
}
I tried to just put LEDs on HIGH and this didn't flicker, but once I put the command in the loop section, it did.