Mood Light


    This project began when I was surfing the web looking for any cool electronic projects. I found the mood lamp made by Toon Beerten "". I was really impressed by the 3 watt RGB LED. I bought some of those on ebay and made some tests with an AVR with PWM to control each color intensity. At this point I found those LEDs very interesting and powerful, so then I needed a project.

One week later a crazy idea came to my mind. I would light my entire kitchen with LEDs so I will be able to light it with up to 16 million colors. With software I would also be able automatically make the light change colors randomly but with smooth fading effects. As you know with programming you can make any pattern, with only your imagination as the limit. I made a controller with a LCD, keypad, and 4 slide pots, 3 for manual led color intensity, and the other to control the speed of the color patterns changing. This master module communicates in RS485 to all slave devices, each of which drives 2 LEDs. Each of the slaves has their own address so the master control can address the LEDs individually.

I also made group of LEDs. If you want you can specify different patterns to each group. The communication protocol I used is the standard for the lighting control industry, DMX512. It's a very old and simple protocol. Each slave module is given an 8-bit address (the protocol actually supports up to 512 devices), and each 8-bit byte in the 512-byte data packet is the lighting data for the corresponding module. The start bit is done by a framing error.

Finally I had another idea. With 3 colors I can make a music color organ!!! I worked hard on this because I wanted a color organ that would be independent of the sound level and the sound quality. It must work with Elvis to Pink Floyd or to any others. I built an AGC that outputs the same level from 1mV to 10V. Next, 3 filters give you the low, middle and high frequency bands. The last stage is a rectifier that gives a DC voltage level equal to the level of the frequency. This DC is connected to the A/D of the MCU and all of the comparator triggering is done by the software, that like I said, makes any type of song work perfectly. One very important thing is the powering of all the slaves with their 3W LEDs. Each color sinks 350ma, so you must calculate 1 amp per LED. I have 16 of those so it uses 16 amps!!! At 5V, I had to use a PC power supply that can handle up to 25 amps. At this point the rest is not too difficult, but you must think about the resistance of your conductor. At 16 amps it's very easy to lose 1 volt. I used #8 wire, which is the minimum you can use.  


  • 1024 3W RGB LEDs can be controlled
  • Over 16 million colors can be generated
  • Very powerful, can be used as your primary lighting
  • Many patterns are pre-programmed
  • Can be connected to any audio RCA jack and the system will became a Music color organ!!! (It's crazy)
  • Firmware upgradeable via RS232




Color Organ Schematic

Master Unit Schematic

Slave Unit Schematic

Master Unit Source Code

Slave Unit Source Code

42 Comments to “Mood Light”

  • Brian Schimke April 5, 2010 at 6:17 am

    Your website served as a huge inspiration for me in creating my lighting system with an atmega168 and 3w led's. I am very curious to see what effects your color organ had during music playback, a video would make my week! Thanks for inspiration
    - Brian Schimke

  • admin April 5, 2010 at 3:54 pm

    Hi Brian,

    Thanks for your good comment, I don’t have a video camera so I can’t make a small movie, but I can told you that the color organ with 3Wled is just crazy, Normal light take time to lights up but not led, it’s like if you have xenon flash lamp of 3 color that follow the sound of music. And my color orgran with is AGC is very good, you don’t have anything tune up and it’s work with any song at almost any output level


  • MarkSpizer May 3, 2010 at 12:49 pm

    great post as usual!

  • Judy Scott May 4, 2010 at 5:57 am

    Nice information,thanks for sharing,,great pictures to

  • alpa May 15, 2010 at 3:23 pm

    Very good

  • sumin May 27, 2010 at 5:34 am

    Thank you very much for this useful information

  • mike h July 16, 2010 at 6:41 pm

    I love this it is truly awesome. i saw the vid.  i woke up this morning and i just wanted to flash the lights in my room to the beat of some music. now i want to create this.  i am wondering how you got your pcbs made, if you have any left over, or can send along the pcb design files let me know.
    it would be really great if you could send along the full parts list
    also im used to the arduino language but i learn quickly, what language did you use? (looks like c)

  • admin July 16, 2010 at 6:47 pm


    Thanks for the comments, There is nothing more available than what is on my blog


  • mike h July 18, 2010 at 2:47 am

    awe man share the love
    just some quick questions,
    i love your schematics,  can you explain what the 2 5×2 headers are for ans well as how you connected the main board to serial
    please email me

  • admin July 20, 2010 at 7:54 pm

    JP1 is for ISP programming

    J1 is connected to the color organ board

  • mike h July 22, 2010 at 1:54 pm

    thank you,
    again i have more questions,
    in your description you said you could update the program via rs232 but there is no documentation for the atmel suggesting you can, unless you burned a boot loader, is this the case, or is there something in the code i missed.
    and again if you have any sort of file you can send me of your pcb design i would really appreciate it, i want this to be a permanent thing in my basement. so it cant stay on my breadboard. and ive never used eagle before so im not the best at it.
    any help is really appreciated 

  • Sylvain July 22, 2010 at 2:03 pm

    Yes you need a bootloader, check in my megaload section,  Everything I give is on my blog I don't give anything else

  • Mike Hosmar July 23, 2010 at 2:32 am

    allright  megaload U looks great
    one problem trying to compile your code, i dont have <shortnametype.h> and i cant seem to find it if you could email it tyo me i would apreciate it.

  • admin July 23, 2010 at 12:18 pm

    Hi Mike,

    Replace the shortnametype by
    #define ushort unsigned char
    #define uint unsigned int

    I think with that you will be Ok, I will make the modification for my next release

  • Sylvain July 23, 2010 at 12:22 pm

    By the way mike you need the bootloader that fit with MegaLoad U  if you take my old project you need my old Megaload, the U version is not compatible with the old bootloader files

  • Mike Hosmar July 23, 2010 at 7:47 pm

    ok, i did that, but it still wont compile,
    i getan error like this
    MoodLightContDMX.c|637| type error in argument 2 to `csprintf'; found `pointer to char' expected `pointer to __flash char'|
    i tried to switch it to a csprint and it doesnt error there anymore
    but i get tons and i mean alot of  errors like this (in the assembler file)
    !E MoodLightContDMX.s(104): branch target too far for relative jump/call

  • admin July 23, 2010 at 7:55 pm

    it's a change in iccavr from a version to another,  Now you must declare string in flash as static flash char and in the option project setup the option string in flash only


  • Mike Hosmar July 25, 2010 at 8:20 pm

    I have had some problems with your boot loader, but i have gotten the code onto the avr via isp, but all it does is show the startup screen and then it has a stack crash, do you knw what this could be?

  • Mike Hosmar July 25, 2010 at 9:42 pm

    ive narowed it down to something in the DisplayRGB function im not sure what to do about it tho

  • Mike Hosmar July 26, 2010 at 4:56 pm

    i dont know what it is any more,but im still getting stack crashes

  • Mike Hosmar July 28, 2010 at 2:47 am

    ive narroed it down to this line
    Led = (LedStruct*) &DMXBuffer[0];
    without this line there is no stack crash but it  also doesnt do much.
    please help, ive spent a few hours learning about structures and i still have no idea why this doesnt work

  • Seo Experts August 2, 2010 at 4:54 pm

    This was a really informative post, Ive been searching for the last frew pieces for a report. The search is over!

  • aminbahar September 6, 2010 at 12:09 pm

    This is really cool.
    I would like to know, how do you connect between one lamp to another?
    Is it every single lamp has their own DMX address or you just loop it together?
    Can you send me the circuit on how you daisy chain all these things? As I'm actually searching for this, and i'm stuck with how to connect and program/read the DMX address. Do we need to build one circuit for every RGB LED or how?

    Hope that you could help.
    My email is: lilzbit at

  • admin September 6, 2010 at 12:23 pm


    In my project all the led are connecter to is MCU and each led had is own DMX address, so if I have 10 led I have 10 MCU controlling is led and all the MCU are wire with a dmx dasy chain. if you need more info on dmx search the web there is a lot of protocol information.

    Good Luck

  • mathias September 15, 2010 at 2:42 pm

    I will make it for my thesis.
    But is it possible that the AT90S8535 nowhere is to find?

  • mathias September 15, 2010 at 6:14 pm


  • mathias September 17, 2010 at 12:20 pm

    Do you know where can find the software for the program AT90S8535  and AT90S2313?

  • admin September 17, 2010 at 12:50 pm

    - AVRStudio

  • Azim Ishani April 18, 2011 at 11:39 am

    Your project is very interesting. I am unable to find the AT90s8535 & AT90s2313 so i am using ATMEGA8535 & ATtiny2313. So do i need to make any changes to the firmware. 

  • admin April 20, 2011 at 11:14 pm

    Yes you need to change code and recompile, (I can’t help you for that)

  • Azim Ishani April 21, 2011 at 9:43 am

    Thanks mate. Just wanted to confirm. Will do it myself.

  • rousat May 9, 2011 at 11:26 am


  • Francis August 24, 2011 at 10:48 am

    Un copié coller de Word vers votre éditeur de texte a dénaturé mon texte, voici le texte original.
    J'ai réalisé votre Mood Light uniquement l'esclave puisque je souhaite le commander avec l'interface USB to DMX de Enttec, mais j'ai un problème je ne trouve pas sur votre site internet la valeur du Fuse LO et HI à mettre dans l'ATtiny2313, j'ai probablement raté quelque chose. Doit-on aussi utiliser le bootloader pour l'ATtiny2313 ?

    Bien à vous

  • admin August 24, 2011 at 11:20 am

    Pour le code copy le dans le notepad et recopie le dans le compilateur qui en passent doit absolument etre ICCAVR puis tu doit mettre ton tini2313 en mode at90s2313, pour le reste tout deverais etre Ok


  • SiGNe September 13, 2012 at 12:53 pm

    I'm from Holland so i'd really like to know how much all this costs…

  • admin September 13, 2012 at 12:59 pm

    Hmmmm the original lamp, 50$, 3led at 10$, CPU, PCB, Driver 30$ something like that

  • Ciro Greggio September 6, 2013 at 12:03 pm

    Great job! Thank you for sharing this cool project. I got some question on this. 
    1- Pin8  of JP1 header (AGC)  in the colororgan schematic is not clear to where it should be connected. I can't see  a track named (AGC or Automatic gain control). 
    2- What does the DIP-SW do in the slave board?
    3- The wiring schematic of the RGB LEDs is missing here in this page. That would be great if you add it  or give us some hints on how connecting the LEDs to the slave board.
    Thank you so much

  • admin September 6, 2013 at 10:45 pm

    1- it’s a flat cable so pin to second pin
    2- Slave adress
    3- each color to the +5 and the color output

  • Ciro Greggio September 13, 2013 at 6:28 pm

    Thank you so much Sylvain. One more question and I won't bother you anymore!
    In the COLORORGAN board, there are two voltages used. Vcc1 and Vcc2. Can I use two separate +5V DC supply voltages?
    MC33202 can operate up to 13 volts (vcc to gnd) I wonder if I can another +5v for vcc2 or it should be lower than 5v?

  • Ciro Greggio September 15, 2013 at 4:54 pm

    Wow It works!  I built it up successfully.But I hardly found the At90s chips with a very high price. this is the only drawback. I tried my best to adapt the codes to work with ATMEGA8535 and Attiny2313 with no success! It would be so great if the code was written for the new chips I mentioned before.
    P.S. I designed  the PCB  for All three boards with Eagle format. let me know if you guys need them.

  • admin September 16, 2013 at 2:32 pm

    VCC is 5v and VCC2 is build by the cicuit check on the bottum of the page, VCC2 is VCC / 2

Post comment

Please note

All my source codes were taken from my personal projects.

Everything is for your information only. The C/C++ codes have been written
with ICCAVR. You can find the header and source CRT files by downloading their compiler.

All is for your information and everything is AS IS without any warranty of any kind. No other files are available and I don't make any modification for any body.



Electronic Links


AGC Anemometer AVR AVR Bootloader Bootloader Capacitence Capacitor Clock Color Control DCC Debugger Devices Digital driver Function Generator High Gain Microphone Humidity Inductance Inductor Laser LCD LED 3W Library Lightning Detector MegaLoad Meter Moodlight Mood Light MS5534 Nixie OscilloScope projector Rain Fall Sensor rgb RGB LED Scop Sensor SHT75 Temperature Terminal Tipping Bucket Train Modeling Vintage Water Detector