First attempt: Controlling the LED driver brightness via PWM/arduino

This video shows an example sketch that controls the dimming on each channel (blue and white) independently.  You’ll see it go from 100% to 50% to low on each channel, and then slowly fade from 0 to 100% and then back down again, then repeat:

I now have pwm dimming set up and working on my tank via Arduino.  The whole system is operated by a regular programmable timer.  The timer turns the whole system on at 10:00 and off at 22:00.  The Arduino turns on with the timer (5v power is fed to the arduino via the Steve’s LEDs controller), and ramps from 0 to 100% on both channels over the course of six hours, and back down to 0% during the next six hours.  This, of course, is the first draft of the Arduino sketch and has one major shortcoming (outside of lack of on-the-fly programmability and user-feedback): if the power goes out, it starts back over at 0% output and begins ramping up again.  This isn’t a big deal if you rarely experience power outages, but could really mess up your tank’s usual light cycle if there are any power interruptions.

Here’s the Arduino code:

// This skectch brings LEDs from off to full brightness over a period of 6 hrs
// Then it dims down to off over a period of 6 hrs allowing for a full 12 hour
// cycle when controlled via an external timer.
int BluePin = 9; //this is the pwm output for the blue channel
int WhitePin = 10; //this is the pwm output for the white channel
void setup()
{
 pinMode(BluePin, OUTPUT);
 pinMode(WhitePin, OUTPUT);
}
void loop()
{
 for (int i = 0; i<255; i++)
 {
 analogWrite(BluePin, i);
 analogWrite(WhitePin, i);
 //delay for 84.375 seconds.
 delay(30000);
 delay(30000);
 delay(24375);
 }

 for (int i = 255; i>0; i--)
 {
 analogWrite(BluePin, i);
 analogWrite(WhitePin, i);
 //delay for 84.375 seconds
 delay(30000);
 delay(30000);
 delay(24375);
 }

}

In case you are wondering, the ‘84.375 seconds’ value in the sketch corresponds to 256 slices of six hours.  The analogWrite method accepts values from 0 to 255.

Schematic: