When I first heard about it, I thought that using a high power RGB LED to build a
color changing decorative lamp was a great idea. (Original post on Make : DIY Mood Lamp). So when my friend told me he was ordering
similar high power LEDs (prolight 3W RGB, picture on the right), I had him buy
one extra for me to play with.
My goal was to control the lamp from an USB port, in order to be able to change it's
color according to different events or system statuses. For instance, flashes upon
new email reception, controlling the intensity of a given color according to
the system load average or according to audio output...
So using the components I had on hand, I built a simple prototype. Next, I quickly
put together a firmware to control the intensity of each color separately according
to commands transmitted through USB. I also created a simple standalone mode where
the color slowly rotates.
My friend which had bought a few identical high power RGB LEDs really liked the results
and decided to build USB lamps based on my circuit. So we agreed that I would design
a PCB which would make it possible to easily build many units. (See picture on the right)
May 2011: Finally after 4 years, wrote the remaining parts, translated to english and published this project.
February 2007: Most of this page written.
The LED used is a 3Watts RGB led from prolight. Here's the datasheet:
3WRGB.pdf. The datasheet reveals that the absolute maximum
current for the Red part is 385mA, and 350mA for the green and blue parts.
Such a powerful LEDs produce a great light output, and produces a relatively high heat
output as well. Cooling is therefore necessary to prevent self-destruction, and to
keep the light output from dropping. (Output drops with rising temperature, see curves in
I used an old heat sink (Destined to socket 7 CPUs, e.g. Pentium 1) and thermal joint compound
to help heat transfer from the LED to the heat-sink. I drilled holes in the heat sink and used
sligtly bigger screws. Thanks to aluminium's malleability, I managed to install the screws without
tapping the holes. Self tapping screws would probably have been a good choice here.
Pâte thermique? (Thermal joint compound)
Pâte thermique appliquée
Wiring on multiuse-tiny1 circuit
I used an Atmel atmega8 MCU running at 12Mhz (necessary for the software USB). I
happens to be one of my common circuits I use for many things, the
Multiuse tiny 1. The more modern
Multiuse PCB2 would also be
usable, but it did not exist back then.
This circuits has all the components necessary to use the
Objective Development V-USB software-only USB,including
the zener diodes which are required for maximum portablity. This picture shows
where I soldered the USB wires and the 3 PWM outputs for the red, green and blue leds.
The other wires are used to (re)program the AVR.
I was aiming at fully powered by USB solution, but the USB standard does not allow a
device to draw more than 500 mA so I had to raise the resistor values for each channel.
I targeted 150mA per channel, total 450mA. The remaining 50mA is more than enough for
the other components in the circuit.
Darlignton transistors and resistors
Driving the LEDs directly from MCU pins was of course out of the question. According to
the datasheet, the limit would be 20mA per IO pin, with a total for the chip not exceeding
300mA. The MCU pins are therefore controlling transistors big enough to cope with the LED
Here's how the transistors are wired ot the Atmega8: Circuit explaination:
When the atmega8 io pin is high (5 volts), the voltage on the transistor base equals
the emitter voltage so no current is flowing. If there's no current flowing between
the base and emitter, there won't be any between the emitter and collector. In other words,
the LED is off.
But when the atmega8 io pin is low (0 volts), there is a voltage difference and therefore
a current flowing from the Emitter to the base. The R1 resistor limits the current to a
reasonable but sufficient level. This small current between the transistor emitter and base
translates to a larger current flowing from the emitter to the collector, and then through
the LED, which will turn on.
Now about selecting resistors for the LEDs. First, we need to know how many volts will
be lost in the circuit. According to the datasheet, at a 150mA current, the red LED will
have a 2v voltage drop, and the green and blue LEDs will exhibit a 3.3v drop. The transistor
also incurs a voltage drop. For instance, the 2SB1067 transistor I used would have a 0.9v
drop at 300mA when operating at 25°C. All of the above will also depend on temperature and
vary between components...
Calculating the ideal resistor value for a 5 volt supply and target current of 150mA. Transistor voltage drop (Vce)=0.9V.
LED Voltage drop
(5V - 2V - 0.9V) / 0.150A
(5V - 3.3V - 0.9V) / 0.150A
(5V - 3.3V - 0.9V) / 0.150A
Here are the real life results measured on the prorotype, with non-optimal resistor values (I used
what I had on hand to get close enough). The voltage drop for the green and blue LEDs was lower than
expected while the red LEDs is pretty close to theory. The USB supply voltage was only 4.86 volts. This
may be losses from the USB cable. The voltage only drops this low when the LEDs are on... Also note
the transistor voltage drop of only .7 volts instead of .9 volts.
Real life LED voltage drops and currents
Voltage accross the resistor
Since I did not use the correct resistor values, the prototype exceeds the 500mA limit by 20mA. When
the 3 LEDs are on, the total current is not 620mA (sum of the above currents) but only 520mA. Nothing
bad happened, but it's still a bad idea to exceed the specified 500mA limit.
That said, I will now reveal the resistor values I used (NOT GOOD FOR USB, too low) for the prorotype:
Blue and Green: 4.7 ohms, Red: 7.9 ohms (6.8 ohms in series with 1.1 ohms)
Ideal resistor values based on real life measure (transistor Vce=0.75v)
(5V - 2.08V - 0.75V) / 0.150A = 14 ohms
(5V - 3.23V - 0.75V) / 0.150A = 6.8 ohms
(5V - 3.12V - 0.75V) / 0.150A = 7.53 ohms
Here's a few pictures of the working prototype:
Blue led only, at a very low intensity
The red led at full power, in a well lit room
Shorlty after completing the successful protype, I began working on an easily reproducible version. In
other words, a PCB and a list of components that were easy to find at the time.
I designed version 1 with the following changes, improvements and goals in mind:
Add a separate power input to provide more power for the LEDs.
Support an input voltage above 5 volt. Failure: The resistors heat
too much. Would need higher wattage resistors or more efficient circuit.
Use a single PCB for all components. No more wires and separate transistor
circuit. (Ok, only wires to the LED)
Use compoents easy to find in 2007 at my usual supplier,
Schematics in PDF format:
Bill of material:
open-collector output buffers
12 mhz crysta;
2A 20V Diode
68 ohms resistor
470 ohms resistor
Diode Zener 3.6 volts
Note: You can use the new ATMEGA8A-PU MCU if you cannot find the ATMEGA8
That's not all!
The transistor is not the one that was used for the prototype so we need to recalculate the
resistor values. According to the MPSA63 datasheet, the saturation voltage (Vce) would be
1.5v. But in practise, is appears to be only .75v..
Mais en pratique, le transistor ne semble pas se comporter ainsi. Le voltage Collecteur-Emetteur est de seulement 0.75 volts.
Resistor values for 150mA and 300mA targets, with transistor Vce=0.75v.
(5V - 2.08V - .75V) / .150A = 14.5 ohms
(5V - 2.08V - 0.75V) * .150A = 0.33 Watts
(5V - 2.08V - .75V) / .300A = 7.2 ohms
(5V - 2.08V - 0.75V) * .300A = 0.7 Watts
(5V - 3.23V - .75V) / .150A = 6.8 ohms
(5V - 3.23V - 0.75V) * .150A = 0.15 Watts
(5V - 3.23V - .75V) / .300A = 3.4 ohms
(5V - 3.23V - 0.75V) * .300A = 0.30 Watts
(5V - 3.12V - .75V) / .150A = 7.5 ohms
(5V - 3.12V - 0.75V) * .150A = 0.17 Watts
(5V - 3.12V - .75V) / .300A = 3.8 ohms
(5V - 3.12V - 0.75V) * .300A = 0.34 Watts
Now that we know the resistor value and wattage, we need to buy these. It is important to use
resistors with approximately twice the calculated wattage.
If you will be powering the circuit from USB (i.e. 150mA per color) and you cannot locate a resistor
with the exact value, you should use a higher value (for a current slightly lower than 150mA). But if you will
be powering the circuit from another source (with 300mA target), you may use lower resistor values
(for higher current) since the real limit is 350mA, not 300mA.
15 ohms, 0.6W resistor
7.5 ohms, 2W resistor
Pair of 3.6 ohms, 2W resistors
Slightly more accurate for RED at 300mA
6.8 ohms, 1W resistor
3.3 ohms, 1W resistor
7.5 ohms, 1W resistor
3.6 ohms, 2W resistor
A good choice for an external 5V supply would be p/n T977-P6P-ND from digikey.
PCB for version 1
Here's a composite view of the PCB:
I used an open-source software named PCB
to design this circuit. Here's the source file for the circuit in
this software's native format:
If you cannot use the original file, here's the PCB in gerber
The pictures below show the PCB assembled for an external power supply where the LED will operate
at approximately 300mA per color component. The MCU is powered from USB or from the external
The intensity of the light output by the LED is controlled by
changing the duration of a period where the LED is on versus
the duration of the period where the LED is off. The operating frequency
was chosen to be high enough for the human eye to perceive a continuous
output whose intensity will depend on the ON-OFF ratio.
The MCU source code is here:
On a linux system on which the AVR development tools have been installed (avr-gcc, avr-libc, etc),
you only need to type 'make' in the directory where you'll have extracted the archive. Have
a look to the 'fuse' and 'flash' makefile targets for programming the AVR. If needed,
have a look to my
How to program an AVR page for details on how this is done.
The USB software-only implementation is an old version of
V-USB par Objective development.
(I'm sorry, but for now I don't have the time to update this project to a newer version of V-USB).
Host PC software
Included with the source archive above, these are simple tools that can be used as examples and
should be easily adapter to your needs. They all use libusb
and were tested under Linux only.
Simple command line tool.
LED controlled by system load and strobe demo.
Simple GUI using sliders to control the LEDs based on the QT library.
Pictures of the circuit, in-use
Démonstration de l'éclairage. Il y avait aussi une petite lampe de 20Watts et un écran d'ordinateur
dans la pièce...
An area in my LAB lit in red...
and in purple...
then in blue...
now in green...
and finally orange.
If the light goes through a small paper cylinder, we can project a circle like this. We can
then witness an interesting phenomenon due to the fact that the red, green and blue light
source come from different spots inside the LED... (The Red+Green+Blue picture is
the most interesting)
Red + Blue
Green + Blue
Red + Green
Red + Green + Blue
Pictures from the living room with no light source but the LED:
If you build this project, I would appreciate seeing your pictures and publishing them
in this section if you allow it.
I cannot be held responsible for any damages that could occur to you
or your equipment while following the procedures present on this page.
Also, I GIVE ABSOLUTELY NO WARRANTY on the correctness and usability
of the informations on this page. Please note, however, that the procedures
above have worked in my case without any damages or problems.