Skip to content

3D RGB Xmas Tree Light Chaser

How are you getting on experimenting with your Raspberry Pi 3D RGB Xmas Tree? You can create some cool effects with the LEDs and minimal coding. I’ve been experimenting with mine, and wanted to create a tree chaser light effect so the lights appear from the bottom, before this can happen I needed a map in the order of which the LEDS light up.

I used a simple program to simply set tree[index].colour = 1, 1, 1 where index = 0 – 24, and that resulted in the map below. you can print it out and stick them together to create a more visual map of the lights.

Updating the modified program from https://muckypaws.com/2020/12/25/merry-christmas-2020/ I’ve added a simple list of the order of LEDs and amended the code that updates the colours from a PNG file.

# Pattern List of the order of LED Light on the RGB Xmas Tree
# Starting from Front Left, working around the tree anti-clockwise
# Be Creative, create light chasers!
XMASLEDLIST = [7, 20, 25, 1, 8, 16, 17, 13,     # Bottom Row
               6, 21, 24, 2, 9, 15, 18, 12,     # Middle Row
               5, 22, 23, 3, 10, 14, 19, 11,    # Top Row
               4]     

and modified the main loop

                for index in XMASLEDLIST:
                    offset_x = (x * channels) % (pattern_w * channels)
                    r, g, b = row[offset_x:offset_x + 3]
                    tree[index-1].color = r/255.0, g/255.0, b/255.0
                    delta+=DELTA_OFFSET
                    offset_y = int(delta % pattern_h)
                    row = pattern[offset_y]

If you want to run the code in Debug and see the lights switch on individually add tree.update() before the delta+=DELTA_OFFSET and set your breakpoint on the delta+= line of code.

If you want to grab the latest code, you can go to https://github.com/muckypaws/Raspberry-Pi/tree/main/RGBXmasTree or clone the repository using git.

git clone https://github.com/muckypaws/Raspberry-Pi.git

Happy Pi’ing and Here’s to a much better 2021.

Jason

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: