Mood lamp

Hello World!

In this post, I will show you my RGB LED powered mood lamp. Now for first, let’s see the result:

It was placed into a cheap lamp enclosure from IKEA. I took out the original 230V socket, and placed my panel in.

It is powered by two simple RGB LEDs. In daylight, it hasn’t got so powerful light…

But in the dark, it looks pretty cool 🙂

The schematic is very simple:

It can be powered from 5V DC at maximum.

The first concept was to make a lamp, which continously changing it’s color components randomly. It was working, but most of the time all the colors were more or less lighting, and because of this, the lamp had always white or almost white color. It was not exactly what I expected. So the second aim was to make an array with the colors I would like to see, and the lamp is fading around these. When it reached a color from the array, it waits some time, then moving to the next color, smoothly. You can customize it to your favorite colors…

The atmega8 is probably too heavy for this project, but I had no attiny controller, when I built it. It has two RGB LED, one was too dark. They are regular RGBs, without diffused lens. That was a little problem, because they had 3 different light and I couldn’t mix them to produce colors. So I got a nail-lile and diffused them manually :). The LEDs are controlled on different AVR pins. The reason is that, I will hopefully write an advanced code to control the two LED differently.

The code is very simple. It is based on a softPWM controlled by a timer. SoftPWM because in this case we can have as many PWM channels as many pin we have on the device. Now we need 6 for the two LEDs.

The algorithm is just a comparison between the PWM data (the brightness of a LED) and a running variable:

The bright array stores the wanted color intensity for the 3 color component. All of the array members are compared to the soft_pwm_var. When the soft_pwm_var is reached one of the component’s brightness, ot turns off the pin. When the soft_pwm_var is overflowed from 255 to 0, it turns every pin on.

There is a speed variable in the code. You can set it to lower than 30, to make the changing faster.

The final version looks like this:

The LEDs are rounded to light to different places of the lamp.

And finnaly the lamp in action 🙂 :

Unfortunately the colors are not so cool on the video, it’s much better in live.

Here is the complete code with comments.

Have a nice day!


Comment Pages

There are 3 Comments to "Mood lamp"

Write a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">