Automatic aquarium light

Hi

First of all: this is going to be my first attempt at programming and building at a higher level.

My project is going to be:

LED lighting which resembles 24 hours of lighting.

Starting with a blue, dimmed light during the night, going through sunrise and progressing into a full power sunlight at “noon”. And then going back through sunset into the blue, dimmed light again.

I know it requires controlling the voltage for each color.

But beyond that…

I saw a bunch of youtube videos on how to create a dimmable, color changing LED lighting for my aquarium. But none of them was “for dummies”. One required a lot of equipment, like oscillators, capacitors, DS1307 64x8 serial RTC and a lot more.

There has to be an easier way to do it, and I know it´s quite a mouthful as a beginner :blush: But I hope someone could stear me in the right direction

What programming and electronics projets have You pulled through before?
You ought to incoporate a Real Time Clock in the build.

You need to study, Google Arduino + "the type of LEDs" You might use.

It ought to be doable. Whatch out for the power consumtion of the LEDs and the voltages You will need.

Railroader:
What programming and electronics projets have You pulled through before?
You ought to incoporate a Real Time Clock in the build.

You need to study, Google Arduino + "the type of LEDs" You might use.

It ought to be doable. Whatch out for the power consumtion of the LEDs and the voltages You will need.

Absolute basic High/Low and delay on the Arduino. But have worked with regular PLC´s before.

I found a Full Color RGB LED Strip Driver Module Shield for Arduino on ebay, which is powered by a 12V external source and works with 4.5VDC~5.5VDC from the controlling interface. That should take care of the power part.

Okey. One step at the time and it will go fine,
Have You decided what LEDs You will use? Look for the maximum current they might draw and get that size of 12 volt supply. Using a buck converter giving Vcc for the controller would be handy.
An Arduino would be capable to do this but a RTC is mandatory I will say.

/*
 * Here is a sketch I wrote for someone else who was running four channels of LED for 
 * their aquarium.  It calculates the time of day in seconds, then compares that current 
 * time to the fade-up and fade-down intervals for the various channels.  It calculates 
 * the instantaneous brightness for each channel so it recovers immediately when reset.  
 * 
 * It currently uses 2-hour fade-in and fade-out intervals (that's what the poster 
 * wanted) but it would not be hard to specify fade-in/-out start and end times (or start 
 * time and duration) for each channel.  Just make sure none of the intervals cross midnight.
 */
#include "Wire.h"
#define DS1307_ADDRESS 0x68  // This is the I2C address for the DS1307 RTC.  The DS3231 might be a better choice.


const int Blue1Pin = 3;
const int Blue2Pin = 5;
const int White3Pin = 6;
const int White4Pin = 9;


const unsigned long HOUR = 60 * 60;
const unsigned long MINUTE = 60;




// You can adjust this value if the lights are too bright or too dim.  You could even
// change this to a variable and set brightness from a pot in loop().
const int TARGET_BRIGHTNESS = (255 * 3) / 4;  // Target max brightness is 3/4 of full


void setup()
{
  Wire.begin();  // Inteface to RTC
}


byte bcdToDec(byte val)
{
  // Convert binary coded decimal to normal decimal numbers
  return ( (val / 16 * 10) + (val % 16) );
}


void loop()
{
  /////  Get time from RTC into RTCHour, RTCMinute, RTCSecond


  // Set the register pointer to 0 (Second)
  Wire.beginTransmission(DS1307_ADDRESS);
  Wire.write((byte)0);
  Wire.endTransmission();


  //  Read Second, Minute, and Hour
  Wire.requestFrom(DS1307_ADDRESS, 3);


  int RTCSecond = bcdToDec(Wire.read());
  int RTCMinute = bcdToDec(Wire.read());
  int RTCHour = bcdToDec(Wire.read() & 0b111111); //24 hour time


  unsigned long time = RTCHour * HOUR + RTCMinute * MINUTE + RTCSecond;  // Time in seconds


  // This is the schedule.  
  // For each channel, the time the morning ramp-up starts and the time the evening ramp down starts
  // With the date from the RTC you could adjust this for sunrise and sunset anywhere in the world.
  analogWrite(Blue1Pin,   brightness(time, 7 * HOUR,                 17 * HOUR));
  analogWrite(Blue2Pin,   brightness(time, 7 * HOUR + 30 * MINUTE,   16 * HOUR + 30 * MINUTE));
  analogWrite(White3Pin,  brightness(time, 8 * HOUR,                 15 * HOUR));
  analogWrite(White4Pin,  brightness(time, 9 * HOUR,                 14 * HOUR));


  delay(1000);
}


// Calculate brightness based on a 2 hour fade-up period starting at
// a specified time in the morning and a 2 hour fade-down period
// starting at a specified time in the evening.
byte brightness(unsigned long time, unsigned long fadeUpStart,
                unsigned long fadeDownStart)
{
  //  Mid day, light is at maximum brightness
  if (time >= fadeUpStart + 2 * HOUR  && time <= fadeDownStart)
    return TARGET_BRIGHTNESS;


  // Dawn:  fade up the light
  if (time >= fadeUpStart && time <= fadeUpStart + 2 * HOUR) // Fading up
  {
    unsigned long seconds = time - fadeUpStart;  // Number of seconds into the fade time
    return TARGET_BRIGHTNESS * seconds / (HOUR * 2); // Fade up based on portion of interval completed.
  }


  // Evening: Fade down the light
  if (time >= fadeDownStart && time <= fadeDownStart + 2 * HOUR) // Fading down
  {
    unsigned long seconds = (fadeDownStart + (HOUR * 2)) - time; // Number of seconds remaining in the fade time
    return TARGET_BRIGHTNESS * seconds / (HOUR * 2); // Fade down based on portion of interval left.
  }


  // The remaining times are night and the lights is off
  return 0;
}

johnwasser:

Awesome. Thanks !

Now i just have to wait for my computer to get back from repair, before i can get to work