In many LED animations, you need to apply a process to all LEDs as quickly as possible. Often this is something like “fadeToBlackBy”, ie “dim all LEDs by a certain amount”. There are some common effects you get with “fadeToBlackBy” and one more action. For example: Cylon effect is “turn on the LED, fade all LEDs towards black, go to the next LED, repeat”. A simple firework simulation is “Random LED on, all LEDs fade to black, repeat”.
Tod Kurt used the Python ulab, a microcontroller-compatible subset of the CPython Numpy library, to do some more number processing:
Since I don’t come from a regular Python background, I haven’t used much numbe. But I knew it was great for vector math. I know that CircuitPython has a simplified version of Numpy called Olab He. She Inherited from Micropython. Although I saw The great learning guide done by Gibbler, the utility of numpy / ulab did not sink. It was only when I was hacking on LED animation acceleration that I no longer stumbled upon ulab. And I’m glad I did.
As a test using a simple fire animation (on the best that Tod can make in regular Python), the results with ulab are amazing:
The general approach is to create a “working copy” of the LED data in an ulab array, and use the ulab functions as much as possible to modify this working copy. Then at the last possible moment, copy the working copy data to the real LEDs object. It just adds a few lines of code to the existing solutions and you get access to all these cool stuff Olab Group Jobs For LED effects!
Stop breading and soldering – start building right away! Adafruit’s Circuit is filled with LEDs, sensors, buttons, alligator clip pads and more. Build projects with Circuit Playground in a few minutes with MakeCode Drag and Drop Programming SiteLearn Computer Science with the CS Discoveries class at code.org, go to Circle To learn Python and hardware together, TinyGO, or even use the Arduino IDE. Speed Circuit Stadium It is the latest and best circuit board board, with support for CircuitPython, MakeCode and Arduino. It has a powerful processor, 10 NeoPixels, a mini speaker, an InfraRed transmitter and receiver, two buttons, a switch, 14 alligator clip pads, and a lot of sensors: capacitive touch, near infrared, temperature, light, motion and sound. A vast world of electronics and coding awaits, and it fits in the palm of your hand.
Do you have a great project to share? The Electronics Show and Tell Every Wednesday at 7 PM ET! To join, head over to YouTube and check out the show’s live chat – we’ll post the link there.
Join us every Wednesday at 8pm ET for Ask an engineer!
No comments yet.
Adafruit has a “Be excellent to each other” comment policy. Help us keep the community here positive and helpful. Stick to the topic, and respect crafters of all ages and skill levels. Be kind, and don’t spam – thank you!
#CircuitPython #LED #Animation #Acceleration #10x #NeoPixels #CircuitPythontodbot #Adafruit #Industries #Makers #Hackers #Artists #Designers #Engineers