Arduino RGB LED Christmas Wreath

About: i like to build things, fix things, create things, and find out how things work in general.
More About amplex »

This is my first instructable. Have been a long time lurker and tinkerer. This year I decided to make a RGB LED Christmas wreath with some cool led patterns. I decided to use an Arduino Uno microcontroller that I had laying around. When looking at controlling the RGB LEDs, I found that I needed 3 PWM pins per channel of LEDs. I found that with the Uno, I could only have 2 channels of LEDs due to only having 6 PWM pins total. From another project, I already had 7 common cathode RGB LEDs laying around, so I assigned 4 to the main channel, and 3 to the other channel.

Supplies:

Step 1: Breadboard First

So I took to the breadboard and assembled all the RGB LEDs on there for testing. Using 2 channels (3 leds in series for one channel, 4 leds in series for another channel), with a common ground from the arduino, I wanted to make some cool patterns. I found some code @ http://forum.arduino.cc/index.php/topic,11293.0.html and it worked, so I started modifying it and came up with some different types of patterns.

Basically, just put 2 LEDs on the breadboard. The pinout for the LEDs I used were Short-Long-Med-Short = Red-Ground-Green-Blue. Connect the grounds together and to the GND pin on the arduino using jumper wire. The PWM pins you have to use on the arduino are 3,5,6, and 9,10,11. Connect LED1 red to 3, LED1 green to 5, LED1 Blue to 6. Then LED2 Red to 9, LED2 Green to 10, LED2 Blue to 11. I didn't use any resistors in this circuit because these LEDs are pretty solid and I haven't had one burn up yet. You could put a 200-300 ohm resistor in front of each pin but I didn't have any low impedance resistors at the time. It only has to work for a month out of every year! =]

Sorry my breadboard picture is so bad, I only got a cellphone camera video and the quality was not great.

showfreeram(); // check RAM left, my Serial strings seem to take a lot of memory, causing lockups once in awhile for some reason.

RGBtest(); // Test both RGB LED Channels. Test LED 1 Red, then green, then blue, then LED 2 Red, Green, Blue

randomSeed(analogRead(0)); }

void dopause() { delay(pause); if (up==1) pause=pause+10; if (up==0) pause=pause-10; if (pause>=200) up=0; // reset timer, timing is now going down if (pause<=0) up=1; // timing is going back up }

void dopause2() { delayMicroseconds(pause*10); if (up==1) pause=pause+10; if (up==0) pause=pause-10; if (pause>=200) up=0; // reset timer, timing is now going down if (pause<=0) up=1; // timing is going back up }

void domicropause() { // delay(VERYQUICKDELAY*pause); delayMicroseconds(pause*10); if (up==1) pause=pause+1; if (up==0) pause=pause-1; if (pause>=20) up=0; // reset timer, timing is now going down if (pause<=0) up=1; // timing is going back up }

// THESE WERE CAUSING LOCKUPS WHEN THEY ITERATE TWICE FOR SOME REASON..

fastblinkswap();

fastblink(); showfreeram(); */

randomSeed(analogRead(0));

randomfadeslow(); showfreeram();

fastRGBblink(); showfreeram();

slowfadeinwhite(); showfreeram();

fastblinkcolorfade(); showfreeram();

fastblinkcolorfademod(); showfreeram();

randomjumpfade(); showfreeram();

fastcolorfade(); showfreeram();

}

Step 2: Construction: Wiring

As you could see in the top of my code, I decided to go with this wiring color scheme, due to the simplicity of it: Orange is closest to Red, Green to Green, Blue to Blue. And the White/Or, White/Gr, White/Bl will be for the second LED channel. The LED's will alternate, 1st will be LED1, 2nd will be LED2, 3rd will be LED1, 4th LED2, 5th LED1, etc.. I used a common ground path back to the Arduino which shouldn't cause any major issues.

For wiring, I decided to use Cat5e as I have a few thousand feet of it around and use it with lots of Arduino projects. I cut strips about 10" long so I would have enough to play with, as you need 2 extra inches per piece to get up and through the wreath, and the wire is so thin and malleable that you can twist it around pretty easy to hide it behind the wreath. I went with white but use any color that will not stick out through the thin wreath. After you have cut as many pieces for which you have LEDs, you will need to strip off about 1" off the end of each cable, untwist the wires, and strip the jacket off of each wire.

If I had it to do over again, I would not cut strips of wire at all. I could measure and mark the lengths I wanted on a solid piece of cable, and carefully strip back the jacket at the marks and slide it down a bit. Then I could just cut the 4 wires I needed to strip back and solder to an LED (Or, Gr, Bl, Br, or W/Or, W/Gr, W/Bl, Br depending on the channel) and there would be a lot less soldering, and no dolphin clips would be required. But the way I did it, with strips of wire, I had to twist each wire with the same color on the next piece so I had a long cable with 7 spots of exposed wire. About an hour or more extra work. It works fine but there is a lot more potential for error this way in my opinion.

PRO-TIP: If you are using superior essex cat5e with the lighter solid colored wire (instead of striped white/green, it is more a light green, same with all colors): Before you start wiring, in a well lit area, cut off ALL the white/brown wires that we won't be using. White/Brown and White/Orange are almost identical in this brand of cable. I did miswire a white/br to white/or in the middle which I didn't notice until the next day when I realized some of my reds were missing in one channel. Luckily I used way too much wire and was able to strip back and peel the correct White/Orange out of cable and solder them back together. Then I wrote the RGBtest() routine which would show each separate color in each channel to make sure its wired right. When you first wire it up and load up the arduino with my code, you will see this test. If you dont see (LED1: Red, Green Blue, then LED2: Red, Green, Blue) you know your pins are off, or you have miswired something. Start at the arduino and check your wiring the whole way down. Even with just 7 leds, you end up with 63 solder points including the arduino header pins (if you use these)!

Step 3: Construction: Soldering

Set up your soldering station. I use the little 'helping hands with magnifying glass' to hold components in place for me. I used to have my wife hold stuff for me when I began soldering in my first apartment. Having two of these 'helping hands' is really convenient. I have to clamp them to my workspace to keep them from tipping with the weight of wire and components on them, they are light. A decent adjustable light with a magnifying glass built in is nice as well. Somewhere around $25 at Fry's Electronics. No I don't have my resistor color codes memorized still. Learned them too late in life I guess.

Bend the leads of the LEDs apart a bit so you have some room to work. Bend the wire around to meet the LED legs. Make sure to heat both parts of the solder joint for 1 second before you apply a liberal amount of solder.

Step 4: Construction: Soldering Part 2

9v battery clip and optional power switch are next. Very simple, cut the red wire on the battery clip. Attach the side with the battery to the middle conductor of the switch. Connect the other side to either other conductor of the switch (or the only other conductor if you use a SPST switch). Solder these guys and either tape or dolphin clip them apart from each other.

Step 5: Construction: Gluing, Sanding

Now, heat up the hot glue gun. I decided that if I am shoving these LED's in possible tight spots in a wreath, if the conductors touch I could blow LED's or short them out, etc. So I decided to hot glue all the conductive areas from my wires towards the top of the LED. Bend the legs of the LEDs back close to one another like they were when you bought it (careful they aren't touching!). Once you get enough hot glue out on the wires, it will be messy and wanting to fall thru the cracks. Go slow and kind of drip it back onto itself (turn it upside down when it starts to drip, and repeat until it stays). Cover the solder joints and the wire all the way to the jacket.

Also if you want to diffuse the LED (make it so you can't see the separate elements inside, make more of a dull colorized glow), you can sand the tops of your LEDs. I didn't do this because they are mostly inside a wreath and I don't mind the clear look. If your LED's are not perfectly clear don't worry about this step, they are already diffused.

Yes my workspace is small and very messy at the moment.

Step 6: Final: Attach to Wreath

At this point, all solder connections and wiring connections should be complete. I would plug everything in and turn it on and run the patterns to make sure everything looks right. At least run the RGBtest() to make sure your LEDs are in the correct sequence, etc. Turn your wreath over and stick the LEDs in it wherever you like. At this point I realized using 7 LEDs sucks because there is a point where both sequential LEDs are the same channel. But whatever, its just a quick basic project and if I ever make one again, I will know to use an even number.

I used black tiewraps to ziptie the cable to the wreath. I also used black electric tape to semi-conceal (and seal) my arduino on this step, except for the USB port so I can program new patterns, after all, I'm a tinkerer.. Luckily an 8" ziptie fit around the arduino, if yours doesn't fit, just use two in series. Also you can ziptie the battery alongside it. I just let the switch hang down just beneath the arduino.

Step 7: Testing, Done!

Put your wreath up and see how it looks. Test out your patterns and make sure everything still works. This is where I noticed I had miswired a White/Orange to a White/Brown and had cut out the other White/Orange, thus all of my other Red wires on this channel were open.

Hopefully your wreath doesn't sit too far off the wall and all of the wires and connectors concealed well. You can see it if you look close, but my wreath has just enough going on that you couldn't really see much.

Now enjoy the fruits of your effort. I had a couple more ideas to mod this guy out, such as an LDR to turn off the lights in the daytime (make sure to get it far enough away from the bright LED's so it doesnt turn itself off!), a pot to control the speed of how fast the patterns change (I would tie it to the cycles variable), and a pot to control the speeds of the pauses to make the effects faster or slower.

Other ideas: Use a rugged audio shield and/or a little speaker to play a few xmas songs, or make an aux input and time it to xmas music playing off your receiver or something.

I'm not sure how long the battery will last for this project, these little LEDs probably use quite a bit of juice since they are like 3 led's in one. I just made it yesterday, and haven't even bought a fresh battery for it yet, so we will see. Good luck!