Arduino - Digital Clock With Aquarium RGB Light Control





Introduction: Arduino - Digital Clock With Aquarium RGB Light Control

For my new fish tank, I noticed that I sometimes forgot to turn on the lights or kept the lights on too long. Since I'm lazy, I made a simple solution for this, and controlled the lighting of my aquarium using an arduino and a real time clock.

Goal of this project:
1. Let the aquarium lights go on automatically in the morning
2. Let the lights switch to blue lights in the evening
3. Turn the lights of automatically at 1:00am.

Edit on November 9th, 2015:

I dug a bit deeper into the code and made the lights gradually change over a 30 minutes timespan. Link to both codes is placed in the Code chapter.

Step 1: Parts List

The parts that I used are:

- DS3231 Real Time Clock module
- Arduino Mega / Uno
- 5050 RGB Led strip
- 3x BV547 NPN transistor
- 12v-5v voltage regulator
- 12v power supply
- 12v connector for breadboard

If you want to show the time on the LCD display (optional), you also need:
- 16x2 LCD display
- 10k potentiometer
- 220ohm resistor

Step 2: Wiring

Wire everything up as shown in the picture. You can skip the LCD part if you don't want this.

Note that the image shows a different clock module than the DS3231, but there was none available for fritzing.


If you use an Arduino Mega, wire up as shown in the picture. If you use an Arduino UNO, the SDA and SCL pins are at a different location. Make sure that you use the correct pins.

Step 3: Code

The arduino code can be found here, on Github: click

Note: The first time you use the DS3231, you have to set the time. You do this by uncommenting line 38 and set the current time, as explained in the rows before it. Then upload the code to the arduino, comment this line OUT again and reupload the script. Otherwise, the time will be reset to the time you put there every time the arduino restarts.

Edit v.2:

In the code behind the link mentioned above, the lights will change suddenly. I rewrote the code to make them change more gradually, over the timespan of 30 minutes. This code can be found here: Github

Step 4: Finish

Now make a nice aquarium cover, put in the RGB led strip and hook it all up!

Later on, I'll try to edit the code so that the change between every phase won't be so sudden, but for now at least I don't have to switch the lights manually anymore. ;)



    • Epilog Challenge 9

      Epilog Challenge 9
    • Pocket-Sized Contest

      Pocket-Sized Contest
    • Science of Cooking

      Science of Cooking

    We have a be nice policy.
    Please be positive and constructive.



    I have never worked with arduino, but this is exactly the project I want to do.
    My idea is to make an RGB ledstrip do 11 hour "daylight", 1 hour fade over "dusk". 11 hour all blue and then 1 hour "dawn".
    How would you go about that?
    I want the red and green channels at different fade times as I want dusk and dawn to look more red.
    Thank you for a great start anyway and thank you for any help you can provide.


    I too made one a about two years back. Almost similar! Has the pump/filter controlled by the clock too. Sadly I lost the code. Anyway this gizmo is running without fault till date.


    can u help me to find the correct code the project you did. i'm trying to do the same thing, but still didn't got any result. thank you.

    Nice! I'm planning to extend this as well. I'm already working on this with an lcd touchscreen, on which I can set the lights color, record temperature and ph and all other cool stuff! This fish tank gave me a lot of new arduino ideas!

    Hi, Very interesting. I have been trying to convert this code to work on a nano. Had to use the analogue pins to drive the lcd, which works ok. I am also using a DS1302 rtc so again I've had to alter the coding to suit. It now compiles ok so I'm ready to wire up. I just noticed though, your code includes pin 6 for white light but your diagram hasn't got it in. Is this just an oversight or are you using something else? 'm a bit of a newbie at programming so I have to patch other peoples code together to get where I want,and I intend to have the final program to read temperature and operate a fan (cold water fish) and also switch the air pump on at certain times, possibly control the speed of the fan too. Even doing these things it looks like the nano has enough pins spare even though the DS1302 needs 3 as it doesn't use SDA/SCL.

    Just like to thank you for inspiring me to do this project, it has been a most enjoyable learning curve . If everything works I may put the code and circuit on here as my first Instructable.

    I succeeded to make it works with an Arduino Mega but I wanted to make it works with my Arduino UNO. I'm able to upload the code to the UNO but nothing is happening. Does anyone know if we need to modify something in the code to make it works on UNO ?

    Hey, when i power up the RTC the display is not working. Is this a power issue ? Im using a chines UNO clone.

    Awesome!! It worked great. The transitions are perfect and everything looks good! The only thing I'd add is to insert a couple more spaces after "Day " on the LCD printout because after the first "Wake up!" you will get "Day p!" since it isn't long enough to overwrite that part of the previous state.

    Thank you very much for posting this!

    Glad to see you added white in your v2 as well as added fades! I'm going to be trying this later this weekend when my RTC arrives.

    Out of curiosity, how come you didn't use the 5V from the Arduino for the RTC and LCD instead of adding that voltage regulator?

    The power of the arduino is too low for the full RGBW strip. You do need external power. ;)

    Sorry- I don't mean for the RGBW strip, but specifically for the RTC and LCD. Wouldn't the 5V output pin on the arduino be enough for those? Isn't that what the voltage regulator is doing, lowering from 12V to 5V for those items?