My Arduino framework for creating animation patterns and mapping them to segments of an LED strip
- Finn Andersen
- Nov 7, 2023
- 1 min read
My Infinity Cube project from a couple of years ago (still need to write something for that...) has a single strip of 336 LEDs, split up into 12 "segments" - one for each edge of the cube.
I needed a way to define animation patterns and map them to the different segments of the LED strip, so I developed my own Arduino library in C++. It consists of a collection of components (classes) that allow defining the segments of the strip (even their physical coordinates in space) and handles the mapping of linear and 3D patterns to them, with automatic scaling and interpolation.
Programming something a bit more comprehensive like this in C++ was definitely a challenge coming from my mother tongue (Python), but was a good learning experience. It took a long time to work out the architecture in terms of what the responsibilities of each component should be and how they should work together, as well as memory and performance optimisation. Doing simple things like dealing with arrays becomes a challenge, and you need to give more consideration to whether you provide or store objects by value, reference or pointer.
I'm quite happy with how it turned out and figured it could be useful for others doing similar things, so I've finally gotten around to polishing it up and publishing it online. Check it out here!
Comments