Festive Tech Calendar 2023
It’s almost my turn to present my video this year on December 13th, for the 2023 Festive Tech Calendar. I chose to do something fun vs. something about the cloud or databases, etc.
This blog post has all the support info on the spinning Xmas tree, along with the RPI playing Xmas music and flashing Xmas colored lights, while the video goes into everything about the Raspberry Pi, why contribute to this year’s event donation and my project demo.
Project Goal
To use a Lego Xmas tree, attach it to a DC motor and use code with a Raspberry PI and a Pibrella RPI hat to light it up, spin it and play Xmas music.
Supplies
- Raspberry Pi (Version 3B or above)
- Adafruit’s Pibrella hat(just a personal preference) Even though no longer made, you can still purchase them on eBay for $10-20 and one of my favorite additions to a RPI
- Connector wires for DC Motor if not already installed
- DC Motor
- Pibrella,Monitor/screen, Mouse, keyboard/touchscreen
- Power supplies for RPI, pibrella and monitor.
- Legos for Xmas tree and base- design is up to creator.
- Adhesive to attach lego connector to DC Motor. I used gorilla glue.
Could also build a “Lego cage” or have the tree separate from the RPI. My goal was to ensure the tree was secure as it spun so it wouldn’t fall over, but after my original motor burned out, I was unable to locate one that didn’t have a substantially faster rotation on the spin. This caused me to change up my code from just spinning to a pulse, but still had issues with the tree spinning off of the base due to the faster rotation.
Software
- Debian or other Linux distribution
- Python 3.x
- Libraries:
- Pibrella, (as I’m using the Pibrella hat, if not, you will need to use a bread board or other component and the libraries to control lights and motor.)
- Time
- Signal
- system used mplayer with subprocess.
- Mp3 downloaded song from the web of Christmas song.
Code
Play_holiday.py
#/usr/bin/env python ###################################################### #Script to spin Xmas tree and play music and lights #Kellyn Gorman, Silk.us #Date: 12/1/2023 #MP3 should be saved in same folder as the script ###################################################### import os import time import pibrella import subprocess def firstrun(): player = subprocess.Popen([“mplayer”, “jingle_bells_178759.mp3”, “-ss”, “30”], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) while True: pibrella.light.pulse(1,1,1,1) #flash lights slowly on pibrella time.sleep(2) pibrella.output.e.pulse(.5,1) #spin motor time.sleep(30) #music and tree spinning time match pibrella.output.e.off() #shut everything back off pibrella.light.off player.stdin.write(“q”) firstrun() quit()
Challenges
As I haven’t worked with Raspberry PI is a few years, it took me some time to get everything up and running. I ended up having to reload the image to a newer OS, build out and install the necessary libraries needed for the project and then came to designing the project pieces.
I was able to get the 2023 Xmas tree from my local Portland Bricks store, but I had to redesign it to have a base that could be attached to a DC motor, which proved to be more challenging. I simply didn’t have a lego that would attach and have significant locking to keep the Xmas tree steady while it spun. If I’d had more time, I might have been able to, but not with the part-time allocation I’d given myself.
The secondary challenge was around the DC motor. Not all motors are the made the same and my first motor was perfect for the application- spinning slow and consistent, it was excellent for the project, but then, after gluing the Lego attachment, I inadvertently got adhesive into the top of the motor and it became glued in place! I tried two subsequent motors, the first had challenges attaching to the tree securely and the second I ended up using, but the speed on both were upwards of ten times faster rotation than the original, impacting the ability of the Lego Xmas tree spinning apart!
If I had more time, again, I would search out for a motor like the first one I had, but they seem less available.
Raspberry Pi Information
For those interested in getting a Raspberry Pi setup, but need more info that the video offered, check out the following comparison data and links to RPI recommendations:
Comparing Raspberry Pi Versions:
https://socialcompare.com/en/comparison/raspberrypi-models-comparison
Raspberry Pi Kit Recommendations:
- RasTech RPI 4 Starter Kit, include 64G Micro SD Card, power supply, cables, etc. $99.79 https://a.co/d/iSEjarD
- Sunfounder Start Kit FOR RPI 4/4B, (RPI not included!). 87 projects, tutorials, etc. $46.99 https://a.co/d/9nI34Uv
- SunFounder RPI Pico Ultimate Kit for the project geek, 320 items, 113 projects, $58.88 https://a.co/d/bCZIVSA
The time for the today’s reveal is above, and do watch to see if I succeed or explode the Xmas tree!