I've put together a circuit to control two LEDS (datasheet) with two Picobuck PED drivers (product page , datasheet ) controlled by an Arduino nano clone. I'm powering the Picobucks and Nano with a 12v 5A power supply, Fritzing sketch attached. (EDIT: there's a 10uf cap on the power to the Picobuck and Nano)
The setup gradually changes the LED colour in a loop, but for some reason the speed of transition has become much faster (like less than a second) than the expected programmed rate (over 20 seconds). It does this occasionally from startup when the power is turned on, but not always. I am wondering if this is somehow a coding or hardware issue?
Additionally, when working correctly, the colour changes of the two LEDs are not synchronised and appear to be at different rates. Is this a coding issue?
Furthermore the two LEDs, even though identical and driven by identical drivers, have a marked difference in brightness. Could this be a limitation of the circuit?
Code attached.
const int redPin = 6;
const int greenPin = 5;
const int bluePin = 3;
const int redPin2 = 11;
const int greenPin2 = 10;
const int bluePin2 = 9;
void setup() {
setColourRgb(0,0,0);
}
void loop() {
unsigned int rgbColour[3];
rgbColour[0] = 255;
rgbColour[1] = 0;
rgbColour[2] = 0;
for (int decColour = 0; decColour < 3; decColour += 1) {
int incColour = decColour == 2 ? 0 : decColour + 1;
for(int i = 0; i < 255; i += 1) {
rgbColour[decColour] -= 1;
rgbColour[incColour] += 1;
setColourRgb(rgbColour[0], rgbColour[1], rgbColour[2]);
delay(75);
}
}
}
void setColourRgb(unsigned int red, unsigned int green, unsigned int blue) {
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
analogWrite(redPin2, red);
analogWrite(greenPin2, green);
analogWrite(bluePin2, blue);
}
Thanks for any advice!