Introduction: Christmas Lights With Atmega328

Christmas is coming and it’s time to start doing something about it. In my case – finally finishing the instructable about my Christmas tree lights.

The idea here is simple: grab a handful of different-colored LEDs, connect them to the LED driver in parallel (making each individually controllable), have fun. This may sound weird considering all the wiring needed, but the practice showed that this works a lot better than your out-of-the-shop lights with their dull hard-wired modes and no customization. The wiring is invisible, the LEDs are hidden in the fir needles, everything is controlled with an IR remote, children and grownups are happy.

Looks easy, but it took me some years to finish this and make it work on an actual tree. I encountered problems in some unexpected places – like wiring, for example. This instructable is intended to help those of you who want to make the same thing without going through months of trial-and-error purchasing of different stuff on the Net.

The project is aimed at moderately experienced people, as you’ll have to adapt it to your hardware. I made a special board for this long ago, you’ll have to invent it yourself. Or you can get one from me, but still, some soldering skills will be needed.

What you’ll need:

- The controller board (Arduino or other)

- The LED driving circuitry. LED drivers recommended, but it’s possible to do this with shift registers and the ShiftPWM library

- At least 48 LEDs of different colors

- 30AWG wire-wrapping wire, at least 100 meters of it

- Soldering and programming skills

- Some time and patience

I’ll provide my sketch, but you’ll have to adapt it to your device.

APOLOGY: I'm sorry for the quality of pictures and videos, as well as of the article itself. They're not as polished as I would have liked. But among the family, the work and a hobby I have to chose the former two. And I needed to publish this Instructable now, while there's time before the festivities.

Step 1: Wiring

Wires were the main problem for me. With your basic Chinese lights, you get a dark green wiring. I was hoping to find same kind of wires on the internet – to no avail. In fact, I spent a year trying, ordering a dozen different kinds, and finally understood that they don’t really matter.

Thing is, your basic manufactured garland is connected in series. From this, two problems arise:

a) Wires are pretty thick, as they need to carry the power for all the LEDs in series, and

b) These wires go from one branch of the Christmas tree to another in plain sight, perpendicular to the branches.

These two problems require the wires to blend with the tree foliage (fir needles). And are not exactly successful in doing this.

With the thing I had in mind (that is, each individual LED having its own wiring, being connected in parallel) things change:

a) You can use really thin wires, and

b) They follow the branch the LED’s on back to the stem of the tree, going away from the spectators’ point of view, thus being effectively invisible.

Bingo! You don’t need the dark green color, you can have brown to blend with the branches, or even cyan-ish like I had, and it’ll still be invisible.

This is something I actually found out once the garland was in place. It works.

Thus, you need some thin 30AWG wire-wrapping wire (like this), either green (that is a bit blue-ish in color) or brown.

Step 2: LEDs

There are sets of ’10 color LEDs’ available on the internet. The colors are: red, orange, yellow, bog-green, green, blue, pink, purple, cold white and warm white. The last two are interesting, as you can do some silver/gold effects with them, but that’s a different story. The remaining eight are ok, and the number is very convenient, what with the LED drivers having 16 outputs. I recommend 3mm LEDs: they’re rather bright while being small enough to hide in the needles.

Those who follow my ramblings know that I’m a bit obsessed with the spectrum, and you can see that the color set is not exactly spectrum-consistent. Most notable is the gap between green and blue colors.

Well, first, the human eye is not that good at discerning these colors; we’re way better with anything that has at least a speck of red in it. Second, there are almost no LEDs available to fill the gap. Granted, there is one supplier of cyan LEDs on Aliexpress, but these are rather expensive (and I found them too late). There’s also a bunch of scammers selling basic green LEDs as ‘emerald’ ones; don’t fall into this. I found that the 10-color set is pretty good; the LEDs do produce visibly different colors.

If you manage to find these cyan LEDs at a suitable price, I’d suggest you replace the purple ones with them (placing cyan between green and blue). The purples are more like UV ones, they’re not very bright but can do some interesting stuff in the dark if something white is close to them. Thus, you can make a separate branch on your garland for providing magic and mystery.

Step 3: Assembly

Soldering the LEDs to the wires takes time; free up a day to do this even for a small 48-LEDs garland. You’ll need (apart from the LEDs and the wires):

- 1.5 mm heat-shrink tubing;

- 2.5 mm heat-shrink tubing;

- Plenty of raisin solution;

and a soldering iron, obviously.

Clean up the end of the wire, wrap it around an LED leg, apply a drop of the raisin solution, solder. Repeat for the second leg. Push the 1.5mm tubing on the first solder joint and shrink it, repeat for the second. Push the 2.5mm tubing on both legs and shrink. The inner shrinking is needed to prevent shorts, the outer for the good looks. No grip is needed, as the resulting contraption is light, fir needles will hold it pretty well. (If your tree is artificial, you may need something to make the LEDs stick)

Do in groups of six, follow spectrum, don’t forget to check that the LED works as it can get damaged during soldering, and remember to mark the anode wire.

As for the length of the wires, I’ve made them 50 cm, and it’s a bit short even for the small-ish tree I had. I had to stretch the wires instead of wrapping them around branches. To my excuse, I intended to make a 96-LEDs garland (still do btw), and this was its upper half. In any case, just consider that you’ll want the wire to follow the stem and then the branch going out from the controller and select the length accordingly.

Step 4: Controller Connection

I used my UltiBlink SL board that was basically designed with this task in mind. Unless you have/order one, you’ll have to make your own. Breadboard won’t work here, so you’ll have to invent and solder something on a prototyping board. LED drivers are better for this task than shift registers (with the ShiftPWM library), as the drivers don’t require resistors for each LED, thus less space, fewer holes, less soldering.

Note that I used the Extension version of my UltiBlink board, the one without the Arduino stuff (to wit, the microcontroller) on its back. I attached the microcontroller board (the round BlinkeyCore) to the extension. Truth is, it was not intended at first; this particular 48-LED garland was supposed to serve as the upper part of a 96-LED garland, with the lower one having an MC on board. Still, it proved to be good as a) I was able to attach the board directly to the tree stem with simple rubber bands, and b) I was able to easily remove the controller board to reload the sketch. I didn’t have to literally sit under a Christmas Tree with a notebook like some geeky Santa. Thus, I suggest you do something similar, that is, have your Arduino/MC board detachable from the contraption.

I connected the LEDs to 48 outputs in 6 batches of 8 LEDs each like this: red, orange, yellow, bog-green, green, blue, purple, pink; repeat 5 times. That is, output 0 = red, output 1 = orange, output 2 = yellow, etc. The sketch below relies on this order for great justice. Make sure you put them on the tree in the same order, going in spiral either up or down. I’d also suggest trying to put same-colored LEDs in more-or-less vertical lines (above or below each other) – all this will make the effects look much better.

Finally, you should consider the power consumption. 48 LEDs require about 1A at 5V when they are all on. You can use a USB charger, but it should be really good and tested, not some cheap crap from eBay that should provide enough juice but doesn’t (like the white one on my photos, I replaced it later). With 96 LEDs I intend to use two, one for each part of the garland, just to make sure everything works as intended. Another possible approach to this problem lies in software: if you make sure no more than 25 LEDs are on at any given time, you’ll be able to run this from any USB charger or even your computers’ USB port. My sketch below doesn’t.

Step 5: IR Control

IR is pretty good and fancy to control the modes on your garland. Thankfully, there’s an excellent IRLib library that covers every need. Also, the IR receiver has a very simple connection.

There are plenty of instructions on using IR remotes with the Arduino, so I won’t be going into much detail here. If you’re not familiar with it, just reserve an evening for getting this done, it’s no rocket science.

Some notes to make it easier are needed though:

1 – There are different IR communication protocols, with the Philips one being the weirdest and the Sony one being the most logical and easy to program. Most cheap remotes use the Sony one thankfully.

2 – If you have some old remotes somewhere in the garage, check them, quite possibly they’ll work ok. I used to use the remote from my TV to control one of my Christmas contraptions, but that’s not the best idea, as the signal gets reflected from walls, thus it can switch channels or something on your TV while you’re controlling your garland. Better have a dedicated one.

3 – Here’s my sketch I use to map the buttons on a new remote working with the Sony protocol. It dumps codes into the serial monitor leaving you to simply copy-paste them. I copy-paste them into this file , that gets included into the main sketch for the garland (below). Quite possibly the codes for the generic remote (called ‘CarMP3’ in the include) already there will work with your one too.

Step 6: Sketch

Ok, this sketch works with the board of my design (48 LEDs). It’s rather messy, too, as I wrote it in a hurry and didn’t have time to clean/comment it. Still, you may find it useful; feel free to grab needed chunks out of it and do anything you wish. The simplest way would be to simply replace all instances of the DMdriver library functions with your ones. There are three in all: test.setPoint (int x, int y) sets the output #x to Y (Y being a 16-bit number); test.clearAll() sets all outputs to zero and test.sendAll() refreshes the info in the LED driver (sends the data there, changing LED states simultaneously). Even without the remote, it’ll work. Once done, check the previous part of this Instructable, map the buttons on your remote and put the codes in the include file.

If you’re a proud owner of an UltiBlink, you’ll be able to run the sketch out of the box (you’ve got the DMdriver library, right?); feel free to contact me if anything goes wrong, you know the address.

Good luck, have fun, ask questions – I’ll try to answer them, happy upcoming Christmas and hopefully I’ll write something new soon!

Make it Glow Contest 2018

Participated in the
Make it Glow Contest 2018