RGB tree for Pico and Pi

Christmas 2021 update! 

I have designed a new PCB to allow the RGB tree to be used with the new Raspberry Pi Pico microcontroller:


This simple board won’t take you long to solder and is available on Etsy. Once you have soldered it, I recommended visiting this Core Electronics’ page for some code but please note:

  • Amend the pin number and number of LEDs to read:
    • NUM_LEDS = 6
    • PIN_NUM = 18
  • Because the tree uses through-hole versions of the WS2812 LEDs, the red and green channels are swapped. So, when you are expecting your LED to show green it will actually show red and vice-versa! You should be able to amend the code to fix this pretty easily, though.

If you have one of my GPIO Xmas trees then you can fit that alongside on the 6-pin header:

Here are my original instructions for assembling the tree:

In 2016 I ran a Kickstarter campaign to produce a miniature Christmas Tree with addressable RGB LEDs for the Raspberry Pi and micro:bit. This page gives some details on constructing the tree and then programming it.

How to Solder the tree.

There are two versions of the tree, one for the Raspberry Pi and one for the micro:bit. The Raspberry Pi version has 6 LEDs, three capacitors, a resistors, a diode and a connector:


The micro:bit version has 5 LEDs, two capacitors, a resistor and a piezo sounder in the centre:


How to build your tree.

1) Solder the resistor in place (bend the leads on the resistor before inserting it into the holes):


2) Solder the capacitors, again bending the leads before inserting them into the holes. Note that the Raspberry Pi version has three capacitors whereas the micro:bit version has only two:


3) Raspberry Pi version only: solder the diode in place. IMPORTANT: the diode has a band/stripe at one end… this MUST go towards the left of the tree (it is marked on the PCB):


4) Raspberry Pi version only: solder the connector in place. Solder just one pin first, check the connector is correctly aligned, then solder the remaining pins:


5) micro:bit version only: this is the best time to solder the piezo sounder in place. Of the four holes in the centre, use the middle two:


6) Now the LEDs! First, take a good look at an LED and notice that it has two long leads and two shorter leads. Also notice that, for each LED, the PCB has a hole marked “L”. This next instruction is essential: one of the longer leads MUST go in the hole marked “L” (to be specific, the long wire nearest the middle of LED).

Push the LED down so that it is approximately 5mm above the PCB. Solder just one of the four connections for now. Check the LED is straight and, when you are happy, solder the other three leads.

Here are views of both models that shows the LED leads:

rpi_tree_side mbit_side


WARNING: when you connect the tree to your Pi or micro:bit and apply power, the LEDs may light immediately at full brightness. These could be very bright and damaging if you look directly at them. Make sure the tree is pointing away and don’t look directly at it when you first apply power.

Generally, when using the tree, be aware that the LEDs are very bright and take steps to avoid damaging your eyes: don’t run them at full brightness.

If you install the software before attaching the tree then you will be able to run it quickly to turn off the LEDs.

Using the Raspberry Pi version.

Update: I have now successfully tested this with a Raspberry Pi 4.

I have put together a simple bit of example Python code with you can download from http://www.pocketmoneytronics.co.uk/downloads/rgb_tree_example.py HOWEVER, please read the notes below.

To use the example code, you need the rpi_ws281x library by Jeremy Garff and Richard Hirst. If you’ve ever used Pimoroni’s Unicorn HAT or 4tronix’s McRoboFace or any other Neopixel-style products then you’ve probably got this installed. If not, the easiest way is probably to use Pimoroni’s excellent installer or to type the following in a terminal window:

sudo pip3 install rpi_ws281x adafruit-circuitpython-neopixel

Due to changes in the library since I first wrote this code, you will need to open the file rgb_tree_example.py and change this line:

from neopixel import *

to read:

from rpi_ws281x import *

With the power switched off, connect the tree on pins 1 to 16, facing outwards as shown:


You can then run the code with:

sudo python3 rgb_tree_example.py

Using the tree with the micro:bit

With the power off, use crocodile clips leads to make the following connections:

  • GND on the tree to GND on the micro:bit
  • 3V on the tree to 3v on the micro:bit
  • SOUND on the tree to leg pin (0) on the micro:bit
  • LED on the tree to pin two (2) on the micro:bit

The best resources for using the tree with the micropython can be found here:

Here is a hex file that you can download to your micro:bit to test the tree. It was written using the PXT editor by adding the ‘Neopixel’ package. You can see a screenshot of the code below. Important: you need to swap the red and green elements otherwise the colours won’t be as you expect.


Here is a screenshot of some micropython which you can download. Again, the red and green components need swapping over to get the colours you expect:


2 thoughts on “RGB tree for Pico and Pi

  1. Pingback: Volunteer website

  2. Pingback: Microbit Neopixel Christmas Tree | Sean Houlihane

Comments are closed.