Switching effects with pushbuttons on Plasma

Hello,

I’ve built a version of the Plasma Stick because I already have a Pico W and the leds. I’ve added 4 pushbuttons and I am trying to call 4 scripts included with the plasma stick through pushing the buttons ( much like what happens on the Galactic Unicorn) but I cannot break the first effect loaded.
Anyone else tried this yet ? Any code I could look over to see how it is done ?
I’ve tried to adapt the Unicorn code but it doesn’t work.

Thank you

On the Galactic it does an " import fire as effect " etc on button press.
And uses custom setups in these folders.
pimoroni-pico/micropython/examples/galactic_unicorn/launch at main · pimoroni/pimoroni-pico (github.com)

Might want to look at those custom py files?
And that main.py file, if you haven’t already?
pimoroni-pico/micropython/examples/galactic_unicorn/launch/main.py at main · pimoroni/pimoroni-pico (github.com)

Hi,

Thanks for the links, I do have a Unicorn and looked at its code. I’ve tried to work something based on that but it didn’t work. The Unicorn imports modules not existent on the Plasma.
I can start one effect but cannot make it to stop and switch when another button is pressed.

I have a Galactic Unicorn, and a couple of Plasma Sticks.
My Galactic is displaying text messages at the moment. All the original code has been wiped.
My Plasma sticks just repeat a fixed pattern. I’m using them as Christmas tree lights on two small artificial trees. I have thought that changing the pattern would be a nice feature. I haven’t actually tried to do it though. It’s on my to do list. Not sure when it might happen though?

I’d probably do this by having a mode variable to keep track of different effects (that you could switch between with the buttons) and then doing different things in your main loop depending on how this is set.

You might need to use additional variables (or even an array, to keep track of the LED states) to keep track of things if you’re using effects that need to remember the previous state of the LEDs (such as rainbows / hue shifting).

I was running something like this when I was running lights on my bike last winter, I’ll see if I can dig out the code.

Found it! Bike lights 2022 · GitHub

I was using a big Plasma 2040 so you might need to adjust it a bit to work with Plasma Stick (and its single button).

1 Like

Thanks @hel =)
This is interesting in a couple of ways. I setup the LED Snowflakes in my living room window for Christmas. On those, press the button and the pattern changes. Being able to do that on my Plasma Stick Christmas Tree lights would be really cool. Maybe even via WIFI.
Plus, I’m keen to use the mode function on my Tufty to show the Pico Vector Clock, or Weather Info, or etc.
Just have to go find my round 2it. ;)

Thank you hel,I appreciate the help. I will look at the code and see if I can adapt it.

1 Like

Just wanted to say thank you again hel.
I was able to modify the code you shared to complete my project. I had a Pico W laying around along with a LED ring and some pushbuttons and wanted to try a Plasma stick build.
Added and modified a bit the scripts and voila, I have it done.

1 Like