Here is (most of) the Python code I used to map and animate 500 LEDs on my tree. The whole project is inspired by Matt Parker from Stand-up Maths on YouTube, so watch these if you haven't already:
- Stand-up Maths: I wired my tree with 500 LED lights and calculated their 3D coordinates.
- Stand-up Maths: Stand-up Maths: My 500-LED xmas tree got into Harvard.
I used a WS2811 LED strip connected to a Raspberry Pi Zero W, and a host computer with a webcam to capture, process and simulate the LEDs.
capture.py
talks to the Pi Zero to individually light each LED and take a picture.process.py
performs some basic image processing and curve fitting to calculate the coordinates of each LED.simulate.py
visually simulates animation programs.
Each file (hopefully) has further explanations inside. Have fun.
- Python 3.10.8
- NumPy 1.24.0
- SciPy 1.9.3
- Matplotlib 3.6.2
- OpenCV on Wheels 4.6.0.66
Dependencies can be installed using: pip install -r requirements.txt
Earlier versions may also be compatible.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.