text.skipToContent text.skipToNavigation

COVID-19 & Shipping Updates

We are currently experiencing an increased volume of online orders, along with delays and general congestion within our freight and logistic networks. Unfortunately, this is resulting in delays getting some of your orders delivered to you on time. Unaffected services are our FREE 1hr Click & Collect we encourage you to use this service if you need your order urgently. We also have a limited Express/Same Day delivery** service that (for a short time) will be offered at a discounted price of $5 per order.
In line with state guidelines, Jaycar company-owned stores in Metro Victoria, Greater Sydney & ACT will remain open for CLICK & COLLECT orders only. We thank you for your support as we continue to keep our community and stores safe.

LED Basic Christmas Tree

Here's a good project for a beginner which can add a bit of Christmas spirit to your workbench and also teach you how multiple LEDs can be controlled from a handful of microcontroller pins. Being Arduino based, the LED Christmas Tree can also be customized to your liking. There is some soldering required for this project so make sure you have an adult's assistance when building the tree. A set of needle-nose pliers will also come in handy.

LED Basic Christmas Tree

Bill of Materials

Qty Code Description
1 XC4410 UNO Main Board
1 XC4482 Prototyping Shield
1 RR0554 Pack of 8, 180 Ohm Resistors
5 ZD0150 5mm Red LED
10 ZD0170 5mm Green LED

Connection Diagram

Connection Diagram



The construction of the tree of LEDs might look a bit tricky but if you following the steps carefully you should have no trouble. We'll start by carefully bending the legs of the LEDs. The legs don't like being bent and straightened and bent again as they will tend to break off.

Start by bending the legs 90 degrees so that they point straight out the sides (1), then about 3 mm further along the legs bend the legs straight down (2). We want to make sure that the legs run outside the main body of the LED. Finally, bend the left leg towards you by about 10 degrees and bend the right leg back by 10 degrees. The result should be like (3).

(1)LED Leg Bends 1(2)LED Leg Bends 2(3)LED Leg Bends 3

You'll notice that one leg is longer than the other. This is normal and is used to differentiate the cathode (negative terminal, and it also has a flat on the body of the LED near it) from the anode (or positive terminal). We'll need to know this later so our LEDs go onto the board the correct way.

The next step is to fit the resistors to the prototyping board - we'll do this because they'll sit lower than the LEDs and they'll be hard to get to if the LEDs went in first.

Fit Resistors

Notice that one end of the resistors is at the fourth row of holes in line with the large hole at the end of the prototyping board and they are spaced three holes apart in line with D1, D4, D7, between D9 and D10, and between D12 and D13. The other end of the resistor is in the sixth row of holes away from the analog pins.

Mounting LEDs

Then we mount the LEDs. The short leg of the LED gets mounted on the end of the resistor leg - this gives it a bit more height. Then the other leg of the LED gets soldered to a hole on the protoboard three holes over and three holes across. For most of the LEDs this means their anode (the long leg) is actually in line with the next resistor over. This should give us the legs of the LEDs running clear of either side of the bodies. Note the colours too - we've done a red LED at the end and three green LEDs in the middle. Keep following the pattern from the above photo as we build up.

Solder the negative lead of the next row of LEDs to the negative lead of the previous row (we do this first because it's shorter). Then solder the positive lead of the LED to the positive lead of the adjacent LED below. If you need to you can now adjust the negative lead.

As we keep building up note that all the negative leads are on the side with the resistors and all of them slope to the right at roughly the same angle and all the positive leads are on the other side sloping the other way. Complete the rows of three, two and one LEDs in a similar fashion and check against the picture below.

LED Pattern

The final wiring step is to connect the LED matrix we have built back to the pins that go to the UNO board. In order, the positive leads go to D2, D3, D4, D5 and D6, while the resistors go to A1, A2, A3, A4 and A5.

Wiring LED Matrix


Download the source code, extract into a new folder, open the .ino file in the Arduino IDE and press upload.

LEDs are rapidly switched on and off in turn - even though it looks like they might all be on. The rest of the program in the loop function cycles through a series of patterns which are set by the values in the tree[] array. You can try changing some of these numbers to see how the pattern changes.

There aren't any special libraries to load or install, it's simply a case of opening the sketch, selecting the board and serial port, and pressing upload. The tree should spring to life with the lights forming a pattern. If one LED doesn't seem to be lighting it might be the wrong way around. If it's a whole diagonal row that's not working then the wiring for that row might be broken or might not be going to the correct pin.


As mentioned above you can change the pattern by changing values in the tree[] array. You might want to add a sensor and have the tree change patterns if a change is detected in the sensor.

If you're interested in how the multiplexing works you can change the following line in the treesetup() function to slow down the scanning. Change:


TCCR1B = _BV(WGM12) | _BV(CS10);




TCCR1B = _BV(WGM12) | _BV(CS10) | _BV(CS12);


This might be clearer to see if you change all the values in the tree[] array to 32767 (so that all the LEDs are activated).

If you are familiar with binary numbers you might have worked out how the sketch knows which LED to light up. If not, the diagram below shows the values associated with each LED - to generate a pattern add up the numbers from the diagram where you want the LED lit. You should see that if you add up all the numbers you get 32767 as we noted above.