This Instructable covers the assembly of a circuit capable of PWM-ing (pulse width modulating) a 9-12v RGB LED strip and programming an Arduino to cycle through a range of colors. I will discuss how to mount a transistor to a heatsink & assemble the circuit but won't get into soldering as some RGB LED strips come with leads (and there is no shortage of great tutorials out there).

You will need:
- A Microcontroller
- Breadboard or PCB
- RGB LED strip
- Battery (9-12v)
- 3 NPN transistors (I'm using TIP 120s)
- LM7805 Voltage regulator (optional, but recommended)
- (4) 4-40 screws (length, up to you)
- (4) 4-40 nuts
- (4) nylon washers
- 22g hookup wire

Update 2015: A lot of people seem to be interested in digitally-addressable LEDs (opposed to LEDs in "series", in other words the ones that blink together vs. individually controllable LEDs), so I added an additional section for these as well (circuit and code). Adafruit produces one variety called NeoPixels and they have an excellent guide.

Step 1: Brief Explanation of the Electronics

If you are new to Arduino and are wondering why more than a few LEDs or other components like motors won't activate when functions are called in the code, its because each output has a current limit of 40mA. In other words, a component cannot draw more than 40mA of current from each channel. To refer to the water analogy of electronics, the "pump pressure" is 5V, and the amount of water is the number of electrons (measured in Amps, or in our case, a much smaller amount - milliamps, mA). To accommodate a load that requires more current than 40mA at 5V, we will use our microcontroller to control a transistor, which will provide a component with power from an external source (the battery).

Without getting too technical, its worth knowing that individual strips are made up of 3 LEDs in series which can be cut with clippers at any junction. If you want to cut the strip at any point, just be sure to leave connection points on each halve. To understand how the RGB LED strip can be powered with 9-12V, you need to know the difference between circuits in series vs. parallel (this page has a simple explanation with great illustrations, and there is a popular Instructable that covers wiring LEDs in series & parallel). Basically, when active components are connected in series, their supply voltages are added together. For example, since an average RGB LED requires 3.3 V and 60mA (at full brightness; each color channel draws 20mA, so R-G-B all on at same time is 20 x 3 = 60mA), each strip of 3 RGB LEDs will require approximately 9.9V (the strip I'm using from Jameco can be powered between 9-12V. Be sure to look at your product's datasheet to prevent frying your components. Not all RGB LED strip is powered in the 9-12V range, such as Adafruit's digitally addressable RGB LED strip). One more thing, these strips are "common anode," meaning the LEDs share a positive terminal (read about anode vs. cathode).

Perhaps the greatest take-away is the power limitation of the Arduino. The next section which shows how to use a transistor can be applied to all sorts of other components (ex. motors, solenoids, servos) that require more than 40mA at 5V.

Note: The same concept applies to NeoPixels, but they require a lower voltage (5V). If the power source is lets say a 9 or 12V battery or charger, the power must be regulated.

Note2: The water analogy turns out to be a pretty poor way to visualize what actually occurs at the electron level. William Beaty explains how transistors actually work.

<p>Hello. Will this make all LEDs do the same thing or can you, for example, make some blink and some run on continuous, depending on the code? I'd like to make a LED hoop, so I need about 2m. I would also like to use it with an Attiny85. Is it possible?</p>
<p>dear author: where are the transistors? just cannot see them. waiting for your answer/</p>
<p>In the first picture, the transistors are visible on the left side of the breadboard and they are screwed into the heat syncs. In the second photo, each component is clearly labeled, hover over each item for a description. </p>
thank you. to be checked.<br>(looking around in this page for the &quot;send&quot; button. hope to guess right)
<p>hi there. had to change email for technical reasons. can i ask basic questions? millions of them but i will restrain myself. </p><p>first, i got this strip of leds, simple, non-addressable. at home i found out it has only two wires, while in your instructable the strip has 4. what is that? could i still atach it to arduino and program it, like all the strip on, off, blink, at my pace? the arduino says 5v, and the strip says 12v. could it work together? ok, enough for now. (i am an old programmer, but know nothing in eletronics).</p>
<p>Your LEDs are probably one color (one channel). The LEDs shown here are RGB (one wire per color and one for ground). </p><p>Regarding power, the Arduino requires 5V and the LED string needs 12v. If you want to use one power source, use a 12V power supply to power LEDs directly and use a voltage regulator (7805) before providing power to the Arduino.</p><p>Step 3 of this instructable shows a diagram and explains this in greater detail. Hope this helps.</p>
<p>I'm trying to build this circuit, but I am not good with schematics. Can some one tell me which holes to stick the wires in the breadboard. I tried using the pictures but I couldn't see some of them.</p>
<p>Thanks for the tutorial. I was thinking of using some digipots to do this. I thought transistors pretty much acted like relays. Does this mean they can step up voltage through c-e proportionally to b?</p>
<p>Never mind. I read on PWM. Awesome stuff! and awesome tutorial too. Thanks.</p>
<p>You have 12v going into the collector of your transistor and 5v from the arduino going into the base. On common transistors, this won't open the transistor to saturation and will impede full current flow. Do the Tip120's not care about this?</p>
The Tip120 allows up to 5A to flow from the collector (12V here) when the base is activated (minimum 0.6V).<br> <br> This tutorial explains the application of the Tip120 in a little more detail:&nbsp;<a href="https://itp.nyu.edu/physcomp/labs/motors-and-transistors/using-a-transistor-to-control-a-high-current-load/" rel="nofollow">use a transistor to control a high current load</a>.
<p>FYI, if you're going to use a BJT, you need a current limiting resistor between the microcontroller and the base of the transistor. Without it you risk damaging the microcontroller.</p>
<p>I know this is post quite old but I'm working on a similar project and what would do you think should I put the value of the resistor? I'm also experiencing other problems here is the link to my questions </p><p><a href="http://www.instructables.com/answers/Why-is-my-RGB-led-strip-giving-lots-of-problems/" rel="nofollow">http://www.instructables.com/answers/Why-is-my-RGB...</a></p>
<p>Can this circuit in combination with the correct program be used to activate the leds in sequence ? or would there need to be a time element along with this circuit ? If so any suggestions ?</p>
<p>No, you would need shift registers in between each LED. Alternatively, you can check out Adafruit's NeoPixel strips (awesome). </p>
<p>haha thank you. I ended up stumbling upon those after researching for a bit. Definitely the way I'm going to go</p>
Is working great with a 5m strip/300 leds. thanks!
<p>I made it with a very quick and dirty copper plated PCB, LM7805 regulator and TIP122 transistors. I had to run my LED strip at 12V, no problems overheating. This is a super simple circuit and now my workshop looks like a frickin night club.</p>
<p>This works great as a stand-alone, but I ran into some unpleasant behavior when using it in combination with one of Adafruit's microphone boards. The common ground between the transistors and the mic causes all sorts of undesired feedback and harmonics on the analog signal. I'm going to try to figure out how to buffer the output but I'm not very skilled with electronics. Anyhow, thought I'd mention this as a potential gotcha for others. Here's my circuit if any benevolent being wishes to debug it. The bit on the top right is a rotary encoder with a momentary switch. It and the resistor associated have been removed for debugging. </p><p>Moving the mic's ground from the common ground to the second ground on my mini helped a lot but I still get more noise than running without the transistors. </p>
<p>You could try connecting some capacitors between the V and GND terminals of the microphone to filter out the noise. </p>
<p>Awesome, thanks for sharing your research</p>
<p>Could you upload your ATTiny85 code somewhere, currently I'm working on this but all I need right now is the tripple pwm :/</p>
<p>I have read that it is possible, though I have not been able to get it working. Would love to see some working code that allows for 3 PWM channels with the 85. </p>
<p><a href="https://gist.github.com/funkfinger/954874" rel="nofollow">https://gist.github.com/funkfinger/954874</a></p>
I'm just wondering, Are you using PWM on your Attiny85?
yes, but only 2 channels
That's Sad, I gueSs I would be better off using an AtTiny 84 for a similar project. Thanks.
I made this last night, works like a charm, thanks!
If you remove the current limiting resistors that are used to protect the LEDs in 12V use, you can get full brightness at 9V.
remove and BYPASS I mean by soldering a wire in it's place.
Or you could save yourself the trouble and just work with discrete RGB LEDs.
Absolutely - but to work with them the way they are wired in these strips, they have to NOT be pre-wired with a common anything - they have to be the 6 lead LEDs like the ones on the strip - otherwise you can't put them in series. <br>If you use the 4 wire RGB LEDs, you would have to use higher value current limiters, and each tri-colour LED would have to be in parallel to the next one.
Ultimately I think the strips are easier to work with, plus they are flexible.
For those that work better visually, here's a diagram that shows exactly how each 3 LED strip is constructed, as explained in the intro. It also explains why the current limiters can be bypassed for 9V operation as each segment of each element would get 3V without it.
another option for power would be an atx power supply (ground the green pin to turn it on) and use the molex (red is +5v, yellow is +12v and black is ground, common to all outputs) for the arduino AND LED strip, as it is a regulated power supply, and if too much current it pulled or something is wrong, it auto shuts off. the reason i like this so much is because i have rgb leds in my case :D <br>
A power supply is definitely the way to go if your project is not mobile. I have bought a few inexpensive ones on Amazon (DC 12V 20A Regulated Switching Power Supply) for around $20, which is much less than what you'll see advertised in electronic supply magazines.

About This Instructable


150 favorites

Bio: Sr. Developer at Disney. Digital Arts & New Media, UC Santa Cruz alumnus.
More by danm_daniel: Ice Crystals: Food-Safe Molds from a 3D Printed Object RGB LED Strip Circuit with Arduino Bubble-Free Resin Casts with Modified Paint Tank
Add instructable to: