Arduino mood light
I recently saw the cool mood lamp by Philips and I liked it. What I did not like was the price. I set myself to discover what the industry has to offer in terms of high-power LEDs. It turns out that since the old 20mA red LEDs the market has evolved in such a way that it seems the light appliances of the future might be completely LED-powered.
Now there are 3W and 10W LEDs available. Either monochrome or RGB. I like LEDs as they last forever (I've never seen a LED that stopped working unless it was due to a current overload).
High power LEDs are not cheap but they are very easy to control from a micro-controller using PWM (Pulse Width Modulation). They need DC low voltage power sources.
I did a test with an Arduino board and a protoboard with a ULN2003 that I've used to control a 3W RGB LED.
I programmed a never ending random sequence and this is the source code. Just connect each led (R,G,B) to the outputs 9,10 and 11 of the Arduino. If you need more current then use a Darlington driver.
Let's see the schematic:
R=22 OHM/3W (for 3W RGB LEDs)
Update: I've added a new "candle" effect playing with random changes on color and intensity.
Update2: Several of you asked me for the candle effect code. I'm posting the whole source file that includes other effects too plus a couple of analog inputs that select the effect and the brightness.
Now there are 3W and 10W LEDs available. Either monochrome or RGB. I like LEDs as they last forever (I've never seen a LED that stopped working unless it was due to a current overload).
High power LEDs are not cheap but they are very easy to control from a micro-controller using PWM (Pulse Width Modulation). They need DC low voltage power sources.
I did a test with an Arduino board and a protoboard with a ULN2003 that I've used to control a 3W RGB LED.
I programmed a never ending random sequence and this is the source code. Just connect each led (R,G,B) to the outputs 9,10 and 11 of the Arduino. If you need more current then use a Darlington driver.
Let's see the schematic:
R=22 OHM/3W (for 3W RGB LEDs)
Update: I've added a new "candle" effect playing with random changes on color and intensity.
Update2: Several of you asked me for the candle effect code. I'm posting the whole source file that includes other effects too plus a couple of analog inputs that select the effect and the brightness.
Comments
You have done my idea, it's more complex and a little bit more expensive but the counter-part is you can build and adapt this kind of ambilight to whatever you need.
Good job!!!
Are you able to post a schematic of some kind so I can study?
Thanks
SiD
If you create a nice design I won't reject a sample lamp though :-)
You can contact me by email misan AT disca.upv.es
Can you tell me a bit about your resistor setup shown in the gallery? I see 7 resistors (can't read the color codes) but they look like 1/4 W ??
Thanks!
My 22 ohm 1W resistor is made of a set of 180 ohm resistors in parallel.
Please note that depending your voltage you may need a different resistor (i.e. if your power supply is not 12V but 10V then you'll need to recalculate the resistor).
I did not have 1W resistors at home :-)
I want to make the same, but with 3x 2.5 Watt LEDs.
Can I use the ULN2003?
Thanks!!
3 leds with 3 colors each mean that you need nine outputs, but ULN2003 just has six, so a second one will be needed (our a couple of bipolar transistors like BC338 instead).
You can tie each color darlington input to the same arduino output pin (so all three leds will show exactly the same color).
Cheers,
Miguel
But I said it wrong, I mean 3 LEDs and each are one color, so a Red, a Green and a Blue LED.
The LEDs I have, are 700mA, but I saw that the ULN2003 only works up to 500mA. Do you now an other alternative for that ULN?
To improve upon this you need to duplicate LED resistor. If the resistor you are using for a LED is R ohms, then use two R/2 resistors in such a way that each output connects one of these resistors to the LED. This way the current share for each output will be fair.
At any rate, you need to check the total power dissipation won't exceed the ULN's. Total delivered current 2100 mA times the saturation voltage of the outputs (around 1 volt) makes 2.1Watts of total dissipated power. Check the specs to be sure ULN won't convert t into smoke.
Thank you so much for the nice documentation. I've just purchase a 10W RGB LED , is it OK to use the same setup as you did? Can you tell me a bit how to come up with the right current and resistor values based on the datasheet of the RGB LED? Thank you so much!
Not sure if you're familiar with electronics or not, but three 2A PNP transistors may work for you plus the UNL2003 that will still be used too, but now just as a driver of your PNP transistor bases (that will need close to 12V when off (a voltage no arduino output can provide).
If needed I can provide you the circuit schematic.
I did not know my cellphone camera was so bad, sorry.
Oops, I can see a resistor is missing from transistor collector and LED in my circuit. Do no forget to add it or LED will be destroyed!! Resistor value will range from 4 to 8 Ohms depending on the color (my advice is to first have it working with 20 Ohhms though).
James
Bhante.
You may want to check this out.
thanks for your descriptions, your code and videos. I did a litte mood lamp with two small rgb leds and my brand new Arduino. It works well, but it needs more power ^^. So I would like to build a amp like yours. For I am new in doing electronic stuff, I would like to know, if this 3W led would fit:
http://www.led1.de/shop/product_info.php?products_id=1032
Does it need a heat sink?
Thanks for your help!
Veit
THe one I used was cheaper.
I'm not using a headsink but do not put it inside a closed box (so air can cool it down),
Can I ask you a question?
I've done a lighting system based on your schemathic. But I ordered rgb leds, and they where with common cathode. How do you think I can modify yours for using those leds?
Thank you very much.
Best wishes
jaume
Common cathode means you have to connect the cathode to ground (GND) and then you have to provide a positive drive.
This cannot be done with a ULN2003 but you can use PNP transistors instead (emiter follower configuration).
You can also use a PNP version of UL2003.
thank you a lot , miguel
So fast answer, so useful!
Supose I can just don't connect the two top pins of the A2981 you told me, and cut the power line (12v) arriving to the led and wire it to ground, all trying to use the printed boards I have done, that are more or less like that: http://4.bp.blogspot.com/_bdWC_nFEbSQ/S93sZHkck0I/AAAAAAAAAB8/Xr79tkVraAI/s400/placa2.gif
The connectors on both sides are: the top one is 12V+, descending ground and the 3 lines of the led colors.
And the four pin in the center
are for the led 3 colors and (suposed) comon anode.
What do you think? I think is that (or similar)or buying some new leds for this project, becouse I have near no time for bigger modifications now.
I also wanted to comment you a modification I thought of your circuit, changing the resistor of the red channel from 22 ohm / 1 watt to 43 ohm / 1 w, becouse that one burned, I suposed it was becouse red line needs less voltage, so that resistor had to dissipate more than what can.
Thank you a lot, you have been very useful for me and my project, and of course you'll be refereed, and this site linked, on it.
regards
jaume
Thanks for this excellent post. I bought one of those Phillips lamps and was extremely disappointed when one of the LEDs burned out within a few months of my purchase. To be able to create my own version would be a dream. I tried to download the candle flicker source, but your site seems to be down, could you repost it somewhere else? I'm new to electronics but am very excited to start creating my own versions of electronic design.
Thanks,
Jarlen
I have a question.
Port 9, 10, 11 (R,G,B)from the arduino will output 5 volts, which goes into the darlington array, which amplifies the current. Since you are supplying an extra 12 volts to the LED's as well, what is stopping them from being "on" all the time?
Darlington is like a switch. If the arduino pin driving it is 5v then current can flow from the +12v through the resistor and LED. Then LED will be on.
But if the arduino pin is low (0v) then the darlington won't allow current to go through so the LED will be off.
Thanks for the explanations.
I would like to know how the ULN2003 (IC) gets it power. Is it throught pin 9.
Thanks.
Contrary to many chips, ULN2003 does not "need power" as you word it. This is because it just packs a few (7) [Darlington] transistors.
You may connect pin 9 to the +12V if you want, but this connection is just not needed in our circuit (though it won't harm if you connect it).
Think of each transistor as a switch that can ON or OFF. A small current delivered from each Arduino output is enough to make switch move to the ON state, no other power is needed.
i'm looking to design an Arduino controled moodlight myself and i was wondering: on one off your picture's you can see your moodlight running while it is on top of the Arduino (like a Shield. but i only see one power input (which is going to the Arduino) so this is 5V. but in your schematic i see 12V for the 3W LED. how does this work? Where do you get the 12V from? and why do you use 12V and not 5V? is this beacause of the Voltage drop across the led?
Great job on your moodlight!
Robin
I still have one question: at wat current is your adapter rated? Because the 3w led will draw about 1A right? But how about the Arduino it self? I know this depends on the number of things it controls but I will only use 3 Pods and 1 push button.
Robin
From the datasheets and forums are quite unlcear about the UNL2003.If i understand correctly the UNL2003 is able to output 500ma on each channel up to a total of 2100ma?
And this would enable it to power two 3w RGB leds with a singel UNL2003?
I am planning to use your schema to build a 2x2m 9 segment wall panel controlled with Arduino. The fire effect would be quite nice.
Thanks for your blog it's quite enlightening.
Willem
You can put two inputs together and then each corresponding outputs will act the same and you can connect a LED to each one.
However, for larger display I would use one power MOSFET for each color, like they do in this schematic: http://picprojects.org/projects/bigmosfetrgb/im/rmdschematic.pdf
The STP36NF0 can handle up to 30A (absolute maximum rating, it is better to stay at half of it, and remember to add a heat sink) per color, that would be 50 LEDs!!
If I have done my calculations correctly a 7,5volt powersupply should be enough to power a single RGB led.
7,5v (supply) - 1,5v(cev max from ULN2003) - 3,5v (led green) leaves 2,5v for the resistor = 7ohm(8,3ohm)
Thanks Willem
I reckon 7.5V would be enough. Just remember each color LED as a different forward voltage and it may need a different resistor.
I'm very much an amateur and I'm trying to put this together, but using a twitter feed to control the RGB values...
My question is regarding the resistors, right now I have 20ohm-1/4W and 1W resistors, which should I use? and how many?
I would really appreciate your help.
Thanks,
mm
Though it depends on the voltage of your power supply. As a first bet I'd go with that value you already have at hand.
However, if you are using a 3W LED then maximum current will exceed even the 1W power rating of your resistors if you keep each color to its maximum brightness. Though I don't think your resistors will burn they will get pretty hot. If you need to be sure you are out of trouble look for 2W resistors (or wire them as follows: put in parallel two groups of two resistors in series).
---+---R------R----+---
....|.......................|
....+---R------R----+
It worked, but it's emitting only RED, which means I wired it wrong.
I have a question regarding power,
In this image:
http://s10.postimage.org/ygf320tiv/board.jpg
Are my assumptions correct regarding the power pins?
Again thanks a lot for the help!
Please remember my drawing calls for common anode LEDs.
Another cause of only the red being lit could be not enough voltage on your power supply (red color is the one that works with a lower voltage).
i collected all the parts for my arduino mood light. i have the following parts:
1x 12V 2A DC adapter
1x 3W LED Star common anode
1x ULN2003
1x Arduino
1x PCB with holes
male headers.
the only things that remain are the resistors but i cant figure out how to calculate them. i saw on you picture's that you use 7 180 ohm resistors. so that is the same as a 1.75W 25ohm resistor. how did you calculate this? because i have no idea what the voltage drop across my 3W LED is.
hope you can help me out.
Robin
I would try the 25 ohm resistor you have and it will go fine. You are not telling me what voltage you have (12V?).
The simplest approach is to use the same resistor value for each color, the only drawback is this way your are giving red color an extra oomph (as red color is the one that works with less volts), but the difference may not be too significant (maybe when you have all channels to 100% you won't get a perfect white, but this may happen even if you balance de resistor well).
Please note that each manufacturer (and model) is going to have different characteristics even if all are rated 3W.
Good luck with the project,
Miguel
i am using 12V.
okay i will try the 25ohm resistor.
is it possible to measure the voltage drop? because if i am correct the voltage drop across a led is always the same right?.
then i could calculate the resistors to get the maximum light out of the led.
Robin
A sample calculation could use this page:
http://ledcalculator.net/default.aspx?values=10,3.6,300,1,0
I just got my arduino moodlight working!
i posted a video on youtube:
http://www.youtube.com/watch?v=sn0CJRpfhBQ
Robin
Miguel
I wired the circuit with 9V and 15Ohm resistors (I bought some 5W :D). Without Arduino/Darlington everything's fine. However, if I connect the LEDs Arduino->Darlington->LED like in your circuit it DOES work but the LEDs are flickering – I measured current across the LEDs and it's far too low... Any idea why?
Thank you!
Paul
If I feed the inputs of the Darlington with 5V directly the LEDs also turn on at full brightness. Only the 5V from the Arduino pins seems to be not enough. Maybe because I'm running that from the USB power supply? The Arduino is doing nothing else apart from setting the three output pins to High.
With the Arduino->Darlington->LED setup I only measure something between 10 and 30 mA which is probably too little for the LED.
Please have a look at the comment on the source code that asks for a couple of 10K potentiometers connected to analogs pins 1 and 2.
Alternatively you can connect analog input 1 to +5v to force the maximum brightness.
Please have a look at the comment on the source code that asks for a couple of 10K potentiometers connected to analogs pins 1 and 2.
Alternatively you can connect analog input 1 to +5v to force the maximum brightness.
im designin a mood lamp as well. i added a pot to change the colors with the help of arduino code that i wrote. it worked. but i was using 5mm rgb leds. not 3 watt one.
so anyways now i got my new 3 watt rgb led since it gives much more brightness. but i have a problem about the resistors. i used three 22 ohm 4 watts resistors. before hooking it with arduino i just wanted to try resistors alone with only rgb led and the power supply which i used 12 volts and 1 ampere. the problem is that the resistors heat up so much that i cant even touch them when the power is on. it does not smoke :) but i bet it will if i let it on for some time. so what is the problem here? i mean the resistors i use are really powerful and quaity ones. btw i didnt connect them to uln2003, do you think its because of this? (which i do not think so)
write me if u have the time.
thanks in advance
Let's see: If you connect a red LED with a 22ohm resistor to 12V you are missing some the voltage drop the ULN2003 will cause and some of the current limit that will introduce too, meaning more power will be dissipated (and more light will go through the LED).
Back of the envelope calculation will give around 9.5V/22ohm = 0.43A which means 4W of power in the resistor which will keep it hot.
Once you factor in that red LED is the one that will use more current (due lower voltage drop) and you use both ULN and PWM (as you usually are not lighting all the colors full blast) the resistors will not get as hot as your test above, but still will get hot.
If you want to reduce the heat you can change the power source to 5V instead, and adjust the resistor values accordingly, but still remember you'll need around 1.5A for reaching the maximum brightness out of your 3W RGB LED.
I am thinkin to use this lamp permanently so for instance i want it to work without problem 8 hours a day. I am makin my own arduino and I will put the circuits and the led in a closed plexi glass box. So thats why my concern was these resistors. Since they get so hot I dont think the lamp will work more than couple days. Dont you think so? Or the resistors will endure bein hot?
Another thing is that if I use 5 volts power source, it will be difficult to find a proper resistor since the forward voltage in green and blue are almost 4 volts. So thats why 12 volts is better to give accordin to me.
So what do you say? Shall use 22 ohm 4 wats resistors with uln2003 and arduino for the lamp?
A 4W resistor can handle 4W without destroying itself, but if you keep it in a closed box the thing can get pretty hot, as you have three similar resistors.
As I mentioned the 4W is only a limit case, red color, constant current and not ULN. Even if you reach 80C, which I doubt, plexiglass will not fuse nor be burned.
I'd say you go for it with 12V and 22 ohms, if you later still find it too hot for your taste, try to use 7 or 8V power supply instead.
I think Ill use 9 volts and 1A adapter. Since I can also use the same rate of source for my arduino with a 7805 regulator. Ill use the same resistors. Maybe Ill get less brightness but it will be much safer.
Take care till the next time. I think Ill bother you time to time ;)
Forward current (IF): 1050MA) Im thinking in wiring in parallel two outputs (also the imputs for MCU), Do you think i need a Resistor if i power it 12V ?
Regards.
A) What kind of light would do the job?
B) Where should the light be placed to get the best effect so the whole wall is bathed in light?
wifi