Now that the holidays are fast approaching -- and a string of LED lights goes for just four or five bucks -- it’s high time to get out your wire cutters and heat-shrink tubing, and make a set of flashy lights that you can control from your Arduino!

In this instructable, I’ll show you how to construct a string of 30 lights (arranged in five groups of six) that you can power from a 16-volt wall wart transformer. Hook it up to a circuit of transistor drivers, and you’ll be able to make the lights bounce, chase and dance via sketches (programs) you’ve uploaded to your Arduino.

Above is a video of one set of lights doing a simple chase pattern. Keep in mind that you can make any other pattern by changing the Arduino sketch.

What You Need:

-- a string of LED lights, single or multi-color, about $5
-- around 50 feet of 18 or 24-gauge two-conductor speaker wire, about $10
-- six general-purpose NPN switching transistors, about $5
(I used 2N3904-type silicon transistors salvaged from an old amplifier)
-- six 4.7K resistors and six 180-ohm resistors, about $5
-- one 5.1v zener diode plus one 180-ohm, 1-watt resistor, about $2
(or use LM7805 voltage regulator to power the Arduino from the same source)
-- a breadboard or circuit board, heat-shrink tubing, a scrounged wall wart delivering at least 16v DC, and an Arduino

Tools: Soldering iron, solder, wire cutters and stripper, electrical tape. A multimeter is handy too.

Depending how fast you work (once you have all the materials), this project might take a long evening or a weekend. Ready? Let’s get started…

Step 1:

Step 1: Major Surgery

Got that nice new string of working LEDs handy? Get out your wire cutter and slice it up! Make a cut about halfway between each socket and the next one. If there are molded resistors in the string, remove them. Most strings consist of three wires: If you save the longest wire, you can use it later. When the cuttin’ is done, your pieces should look like this:

Now, you should have at least 30 bulbs in their sockets, with pigtails of wire attached. Go ahead and strip about 1/4 inch off the insulation on each wire. You’ll be connecting the lights shortly.

Step 2: Step 2: a Little Planning

If you have multicolored lights, now’s the time to decide if you want to put them on the string in any particular order (for example, red, green, blue, yellow, red, etc.) If so, lay them out in sequence, in rows of six. In other words, using single-letter abbreviations for the colors in the example above, the whole long string would look like this:
And the groups of six would be:
Why are we using modules of six lights? A couple of reasons:
The Arduino has six pins that can use pulse-width modulation (PWM), so if you want to have any special dimming effects, you’ll use those pins. It also means that to make the whole new string, you’ll need only three full lengths of two-conductor speaker wire (plus the wire you salvaged from the old string.) As a result, you’ll have five groups of lights that do the same thing at different places in the string -- if you’ve programmed a chase, for example (as in the video), five lights will be lit up at any given time, following each other around the circle.
Of course, you’re not limited to five modules of six. If you don’t mind using the analog pins and some more wire, you can make a string with as many separate modules of any length you want. You can also use a mega board or another method to get PWM from more pins. You may need a different transformer and more components, but the same principles will still apply.

Step 3: Step 3: Sequence the Lights

Let’s look at our example of six lights in five sets (modules):
Light Group  1  2  3  4  5  6
            A         R G B Y R G
            B         B Y R G B Y
            C         R G B Y R G
            D         B Y R G B Y
            E         R G B Y R G
(If you have more or fewer colors, or are using a monochromatic string, adjust the chart accordingly.)
When any of the LEDs in LightGroup (column) #1 is on, all will be on; the same goes for column #s 2, 3, 4, etc. That’s because they’re connected together in series. In other words, in this example, you’ll be putting together six strings of LEDs: two RBRBR, two GYGYG, and one each BRBRB and YGYGY. But don’t connect anything yet! We need to talk about LED polarity.

Step 4: Step 4: Identify the LED Polarity

Unlike incandescent bulbs, LEDs have a definite polarity (positive and negative side.) They also require a current-limiting resistor to keep them from taking too much juice. If you connect them wrong, they won’t light properly -- and may even self-destruct in spectacular style! To hook them up correctly, you need to identify the wire leads connected to the anode (positive part) and cathode (negative part) of the LED. Check the many online resources to help you identify which lead is which.

The above drawing may help.

Look closely at the small LED itself -- which is sometimes found within a molded plastic shell shaped like a traditional holiday light bulb -- and try to identify the larger triangle inside it. (It may be difficult to see at first, due to the way the LED is made.) That’s the cathode, and the wire attached to it gets connected to the negative voltage. When you think you’ve found it, try this simple experiment:

Grab a 9-volt battery and two of the 180-ohm resistors (or one 330-ohm resistor, if you have it lying around.) Gently twist together one wire from each of the two resistors to connect them in series (forming a 360-ohm resistance.) Take one of the as-yet-untwisted resistor leads, and gently twist it together with the anode (+) lead from the LED. Then, hold the LED’s cathode (-) to the negative battery terminal, and touch the remaining free resistor wire to the positive battery terminal. The LED should light up. If it doesn’t, try touching the battery terminals in the opposite manner. If it still doesn’t work, check your twisted-wire connections for shorts or lose wires, see if the battery has any juice left, make sure the resistors are the correct value, or try another LED. Keep trying until you get it to work. It should light up like the picture.

Once you’ve gotten the LED to light, note how the large triangle inside the LED is oriented in relation to the battery terminals. You should see that the wire on the same side as the interior triangle is connected to the negative terminal. But if you can identify some other feature that distinguishes the LED’s polarity (depending on what your set of lights looks like, it could be a marked lead, a flattened side, a tab, etc.) that’s OK too. Just remember what it is. Mark the wire you’ve just connected to the negative terminal with a black marker. Now, find the same feature on all of the other LEDs, and mark those leads black too. You can test each LED one by one, or do a group test in step 6.

Step 5: Step 5: Calculate the LED Series Resistor

As I mentioned before, every LED needs a series resistor to keep it from blowing due to too much current. So now it’s time for a little math.

In order to get the right value for the current-limiting resistor, we need to know the DC voltage of your transformer, and the approximate forward voltage and current draw of the LEDs. The last numbers are easy: because different colors and types of LEDs take different forward voltages and currents, we’re going to take a median value of 2.5 volts and 20 millamps of current. If we’re a bit off, it won’t mater too much.

Ohm’s law says that R=E/I, or (in English) resistance (R) equals voltage (E) divided by current (I). To calculate the resistor we need in this circuit, we’ll use the following equation: V(in) - V(fwd) / I(led) = R(series), where:

V(in) = the voltage supplied by the transformer
V(fwd) = the total (summed) forward voltages of the LEDs
I(led) = the LED’s desired current, in amps
R(series) = the value (in ohms) of the series resistor needed

Plugging in the values from the example, we get:

R = (16 - (5 x 2.5)) / .02 = 175 ohms

But we’ll go up to the next common value of 180 ohms to be conservative (in an electronic sense only.) If you have 220-ohm resistors handy, those should work too.

Notice in the equation that we had to subtract the sum of the LED’s forward voltages from the supplied voltage, and that 20 millamps equals .02 amps.

If your transformer isn’t 16 volts DC, you can use this same formula to calculate the resistor you will need -- or, you can use the handy led series-parallel wizard found here:


Step 6: Step 6: Test the Led Strings

Now it’s time to test the whole string and the transformer, one light group at a time. Let’s start with light group #1, the first column in our chart: RBRBR. Connect those lights in series, as follows: take the first one (R) and connect (twist tightly together) its unmarked (+) lead with the marked (-) lead of the next one (B). Connect the unmarked lead (+) of that B to the marked lead (+) of the next R, so on, until you are left with a bare, marked (-) lead on the first R, and a bare, unmarked (+) lead on the last R. Aside from the colors, the string should look like this:

Connect your series resistor to one end of the string (it doesn’t matter which one), then connect the wires from the transformer (wall wart) to the proper ends of the LED string - negative to negative, positive to positive. I've marked all negative wires black. Make sure you know which wire from the transformer is positive and which is negative! (A multimeter is good to have here.)

All of the lights should glow brightly. Notice in the picture that every (+) lead from an LED is connected to a (-) LED lead -- but the last (+) lead in the light string is connected (through a resistor) to the (+) of the transformer, and the last (-) lead to the (-) of the transformer. Follow the same procedure for the other four strings, confirming that they too glow nicely. Then award yourself a big gold star.

Step 7: Step 7: the Transistor Driver

It would be nice if we could just wire these strings right up to the Arduino -- but alas, that isn’t going to happen. For one thing, the board only outputs 5V, which isn’t enough to power the 5 LEDs in series. For another thing, when lots of lights are on, the current draw could become too high and fry the board. So instead, we will construct a set of transistor drivers to handle the LEDs power. It’s the same type of driver system that’s used for servos, motors, etc.

The transistor is a ubiquitous electronic component which, in this case, we’ll use as an electronic switch. And just like a physical switch, applying a little force to the right place allows us to control a much bigger force -- like squeezing the handle of a fire hose to spray a powerful stream of water. What happens in this case is that a 5-volt signal from the Arduino turns the transistor “switch” on, thus powering up the string of LEDs. When the signal stops, the lights go off. Simple, right?

A diagram of an NPN transistor is shown above:

Applying a small current to the base lets a much larger current flow from the collector through the emitter.

As we found with the LEDs, the trick is to hook it up correctly. Here we’re using a 4.7 K resistor between each Arduino pin and the base of the corresponding transistor, to reduce the current. Each collector is connected to the individual series resistor of one light string, and from there to the series-connected LEDs in the string. All of the emitters are connected together, and go to ground. On the other side, the positive ends of all the light strings are connected to the positive voltage -- in this case 16v. The complete schematic is shown above. Note that, for clarity, only three of the five strings are shown -- the other three are added in exactly the same manner. We’ll talk about the power to the Arduino board in section 9.

Step 8: Step 8: Build and Test the Drivers

Once you get the principle, it’s time to build and test the circuit. I suggest you try it first on a breadboard: Use a 9V battery, a single LED for each transistor, and a 330-ohm series resistor, instead of a 180-ohm, for this test only (the 4.7K resistor going to the Arduino board stays the same.) You can also use the breadboard test to try different Arduino sketches and see what they look like. When you use the circuit to power your long light string, however, be sure to change the series resistors.

Note that you have to use NPN transistors in this circuit. (Look up what that means if you aren’t sure.) If you use PNPs (as I did once, mistakenly), you will get a quite different result: A dark spot (LED off) will travel around the loop -- an interesting effect, but not quite what we wanted here.

I’ve used several different types of small silicon NPN transistors, all of which worked well. But you need to carefully identify which wires are the emitter, collector and base. Not all transistor packages are standardized. Use the various online resources to help, and keep testing until you get it right -- the most common error is probably connecting to the wrong transistor leads.

Here’s a picture of the completed circuit being tested on a breadboard, driving just one LED from each transistor off a 9V battery (and using PWM pins.) When you’re satisfied that it works properly, you could build a finished circuit on a perfboard or an Arduino shield.

This isn’t a bad time to test out a pattern for your lights. You can start by loading a simple LED-sequencing sketch into your Arduino. Here’s a basic 6-light chaser that works by connecting the driver board to Arduino pins 2-7:

   This circuit lights multiple LEDs in sequence
Connect transistor LED drivers to pins 2 through 7, board to power & ground

Created 2006 by David A. Mellis, modified 30 Aug 2011 by Tom Igoe
  and by C Losee in Dec 2011

This example code is in the public domain.

int timer = 200;           // The higher the number, the slower the timing.

void setup() {
  // use a for loop to initialize each pin as an output:
  for (int thisPin = 2; thisPin < 8; thisPin++)  {
    pinMode(thisPin, OUTPUT);     

void loop() {
  // loop from the lowest pin to the highest:
  for (int thisPin = 2; thisPin < 8; thisPin++) {
    // turn the pin on:
    digitalWrite(thisPin, HIGH);  
    // turn the pin off:
    digitalWrite(thisPin, LOW);   

This program will make a light seem to “chase” around the board from one LED to the next. In the whole string, a total of five lights will be on at any given time. There are lots of other sketches as well, but this one is fine for testing.

Step 9: Step 9: Power to the Board

If you’ve worked with the Arduino before, you know it has several options for a power supply: a USB connection, a DC input voltage (recommended 8-14V), and a regulated 5V supply. Because we don’t want to leave it hooked up to the computer, and our transformer is a little outside the recommended range, we’ll construct a regulated 5.1V supply on the driver board.

I used a zener diode and a current-limiting resistor, connected as shown above.

This same arrangement is shown in the bottom right of the complete schematic in step 7. You could accomplish the same thing with a 7805 voltage regulator, with its pins connected according to the package directions; I just happened to have the zener, and a 150-ohm, 1-watt resistor, at hand. In any case, the (+) and (-) from the regulated output go into the Arduino board at the +5V and ground pins. You can use your multimeter to test the output for voltage and polarity before connecting it. We’ll hook everything up in the last step.

Step 10: Step 10: Fabricate the Strings

Grab your heat-shrink tubing and wire strippers and get ready to go to work! You’re going to be cutting and fabricating the actual light set now.

For this instructable, I made a 30-light string with each light spaced 3.5 inches apart. The total length of the string was just under ten feet. If you don’t mind a shorter string but would like your lights closer together (more of a movie-marquee effect), then decrease the spacing between lights accordingly.

Since we’re using two-conductor speaker cable as our wire, we’re going to cut and strip a set of 12 pieces of cable according to the diagram above:

As you can see, we’re staggering the cuts to automatically give us the right spacing when we put it together. One cable is “stepped back” 3-1/2” from the other, and the length of each is 21 inches (3.5” x 6); thus, the total length of each two-stranded cable is 24-1/2 inches. If you’re using a different light spacing, adjust your figures accordingly.

Now the fun begins: Get out your soldering iron, and put your LED light strings in the proper order. Slip small lengths of heat-shrink tubing over the stripped end of each cable. Start with the first light of the first string (in our example, it would be R), and solder its positive terminal to the longer wire on the left. Then solder the negative terminal of the next light in the same string (B) to the shorter wire on the right (which is the other end of the same wire.) Next, take the first light in the second string (G) and solder its positive terminal to the shorter wire on the left (nearest the R); on the other end, connect the negative terminal of the next light in the second string (Y) to the longer wire on the right.

Confused yet? Here’s a ASCII-ready diagram to help you get the picture:

-R+------------------ -B+------------------- -R+ ------------------- -B+ ------------------- -R+
      -G+ ------------------ -Y+ ------------------- -G+ ------------------- -Y+ ----------------- -G+
          -B+------------------- -R+ ------------------- -B+ ------------------- -R+------------------- -B+
              -Y+ ------------------ -G+ ------------------- -Y+ ------------------ -G+------------------- -Y+
                   -R+------------------ -B+-------------------- -R+ ------------------- -B+ ------------------- -R+
                        -G+ ------------------- -Y+ ------------------ -G+ ------------------ -Y+ ----------------- -G+
to +V --------------------------------------------------------------------------------------------------------- + connector

(the seventh wire on the bottom isn’t one of the cables… we’ll talk about it shortly)

Continue connecting and soldering the LEDs in order. As soon as the solder is cool, slip the heat-shrink tubing over the bare wires and seal them up. When it’s all done, we will have achieved two things: We’ve put all our lights in order, and we got the spacing right. (Of course, if you’re using a different light arrangement, adjust accordingly.)

Step 11: Step 11: Complete the Cable

This is the last big step. We’ll start by testing each string. If you’ve done it right so far, connecting the ends of each string to the proper poles of the transformer (not forgetting the series resistor) should give you a glowing result. Just a couple of things left to do:

Remember the schematic? The positive ends of each string get connected together, and to the positive voltage. If you saved a long piece of wire from the original light string, now’s the time to use it. If not, get at least a ten-foot length of single-conductor cable.

Lay the three double-stranded cables down on the floor, and even out the distance between lights -- the spacing should look quite regular. Take one end of the positive cable, and strip, solder and heat-shrink-seal it to the positive end of each LED string in turn: six in total, in a staggered arrangement. Then let it run all the way back, past the last light, and leave it long.

Now, take some electrical tape or cable ties and bind the cables all together, starting at the far (positive) end. When you get to the near (negative) end, stop. Estimate how far you will have to reach from the Arduino controller to the first light. Then, cut lengths of cable at least that long and secure them to the six negative leads at the near end. Tape or clamp those pieces. Voila, le string!

Step 12: Step 12: Putting It All Together

You now have the two major components ready: a completed cable and a transistor driver circuit. It’s time to put them to work with your Arduino. Above is a graphic of what the final result will look like:

You should have a sketch already loaded into your Arduino board, such as the simple chaser from step 8. There are many other LED sketches, from “Knight Rider” style bouncers to ones with variable speed and brightness effects. If you come across a good one, by all means please e-mail it to me and we will feature it here.

Once you have connected your Arduino to the computer and uploaded the sketch, disconnect it from the USB cable. Now, put everything together as follows:

Connect the (+) lead from the unplugged transformer (wall wart) to the LED driver board, observing the proper polarity. Connect the - lead to the board’s ground. Then run a wire from the +5V source (at the zener diode) to the +5V pin on the Arduino, and another from the Arduino ground to the driver board ground.

Now connect the three LED cables: attach the six (-) ends, in order, to the 180-ohm series resistors. You can use clamps, pigtails and wire nuts, solder, or any means necessary -- just make sure they have a secure connection and that they are properly shielded against shorts. Finally, connect the positive LED cable to the 16V positive terminal on the transistor driver board.

When you’re finished, it will look something like the picture.

Ready? Plug it in and behold! If everything went right, you should see the string of lights going off in a chase pattern, or whatever you programmed.

A few observations: Chase patterns seem to look best in dimmer light, in a circular arrangement, and at certain flashing speeds -- not too slow, not too fast. Try changing the delay time (int timer = 200 in the example sketch) to get the best effect: the number is in microseconds, where 1000 ms = 1 second.

If you’ve been testing all along, chances are your lights work successfully. If not, the most common problems are probably loose or shorted connections. Check all polarities, and carefully feel for a hot component if something isn’t working. These components are pretty robust, so even if something’s hooked up wrong, there may be no permanent damage. Go back to the last good test and try again until you get it.

Then you can delight and amaze friends, kids, even dogs and fish with your LED light show. And don’t forget to send along cool sketches for LED sequencing.
<p>In the nicest way possible, I think you'll find 20uA = .02mA = .00002A. <br><br>Nice project, though. I'm very big on all the things that can be done with LEDs now. Fire safety, tiny power consumption and compact size allow a hobbyist to do some amazing things. I made a light strip over 2 meters long with 30 white LEDs for under cabinet lighting. A bit time-consuming, but I love DIY and the fact that it cost me under $10 was pretty nice, too. <br><br>I've also drilled out the end of pieces of clear acrylic rod (both round and hex) to accept an LED and a dab of epoxy. I haven't hit on exactly what I envision yet, but I'm sure there's a technique that will make the light either diffuse or refract in the way(s) I picture it.</p>
<p>Thanks for pointing out the math error, Bob. I have fixed that section based on your comment (the calculation was off as well). Yes, no matter how far you go with this stuff, there's always something great about LEDs, blinkies and acrylic light sabres. Best luck on your projects, and hope you get plenty of slack.</p>
Nice one!

About This Instructable




More by b.orka:Just in time for the holidays - Hack yourself a merry little set of LED Christmas lights 
Add instructable to: