Code Needed for RGB LEDs Controlled by 24 hour Clock.

I am starting an art project that will use LEDs to change color in real-time over a 24 hour period. The LEDs are RGB, or Red Green Blue bulbs. Using these LEDs, I can choose any color in the visible light spectrum. However, the first hurdle of the project will be isolating each color, RGB, and giving each color its own connection to the Arduino. Once this is established, each color will be programmed emit light on a 0%-100% scale. This scale will be “stretched” over the course of 24 hours so that the color is constantly changing throughout the day. For instance, the first 8 hours (00:00-08:00) will be blue dominant, the next 8 hours(08:00-16:00) will be green dominant, and the last 8 hours (16:00-24:00) will be red dominant. Within each 8 hour period will be transitions of the two auxiliary colors to ensure that the entire color spectrum is used (i.e. Red, Green, and Blue light will constantly be emitted).

Put another way, each color will be on a bell-curve starting and ending at 0% light and 100% at the apex of the curve. For example, Blue would be at 0% at 12:00 and 100% at 24:00 and then back down to 0% at the next 12:00. This will allow each color to overlap the other two colors flawlessly. To program this, I will have to divide each 12 hour period by 100. This means a change will occur every 3.6 minutes, or every 00:03:36. This means I will have to program the Arduino to make a change every 3.6 minutes increasing and decreasing light brightness on three channels.

That being said, I will need to program each color of LED according to the bell-curve/time-period relationship so that each color changes in brightness strength every 3.6 minutes. This will also mean that the light will change in brightness by 1% each time. Since a day is not exactly 24 hours, the Arduino will be programmed to reset the counter at the end of 24 hours according to the clock program used. So then, the following is the schedule for the light color and brightness:

Red: 0%@06:00 to 100%@18:00 back down to 0%@06:00

Green: 0%@18:00 to 100%@06:00 back down to 0%@18:00

Blue: 0%@12:00 to 100%@24:00 back down to 0%@12:00

Is there code, or a code I can adjust, to make this work?

Is there code, or a code I can adjust, to make this work?

Probably not.

Given your forum name I am guessing you are not technical. There are some things wrong with what you propose to do.

First of all perceived brightness is logarithmic and that makes it hard to adjust the brightness in a fully controlled way.

Next the eye is not very good at gauging brightness especially when there is no constant reference light to compare it against. To calculate any colour you might need to read this:-

Finally this is not a code writing service. We can help you learn and help you with your code when you get stuck but we do not do it for you.

If you do want to learn start off with an LED fading sketch you will find one under examples in the file menu of the IDE.

Good luck.

I'll assume as an artist that your goal is to be pretty/interesting first and scientific/technically correct last. Divide this project into smaller chunks.

1.) Keep track of time.
2.) Learn to drive a RGB LED.
3.) Use some aspect of time to control how RGB LED is driven.
4.) Scale up to full size.

For step one, get an Arduino and a RTC module (not chip). A RTC module keeps track of time, day, day of week, date, year, and has a battery so it's accurate after a power failure. Use the tutorial associated with the RTC module to get a sketch that reads the time and reports it to the serial port. (Otherwise, how would you see it?) Sparkfun sells a RTC module.

For step two, experiment with a single RGB LED to decide which colors you like. Color blends are achieved by turning the color components on and off rapidly in different proportions. This uses a technique called PWM (Pulse Width Modulation). You will be able to locate tutorials on LEDs in general and specific ones for RGB LEDs. LEDs are also available in strings or chains.

Steps 1 and 2 can be done in any order. When you have the pieces working, it's time to combine them. And as a last step, scale it up for your full project.

You will not find anyone to write code for your project for fun. But you will be able to find pieces you can adapt and combine. If you run into difficulty at that point, posting your code will get you plenty of advise. Good luck.