I have written a short programme in microPython which cycles a string of LEDS through different colour settings (the same colour for the entire string) to simulate daylight and then continuously repeats. I would like a situation where a single button press (RESET?) on the Plasma2040 halts the programme and turns off all the LEDs (ie acts for all the world like an OFF switch). A subsequent press of the same (or different) button restarts the programme from the beginning. Any thoughts on how to achieve this or am I asking the impossible?
Have a look at this button code for the PICO Display. It can be adapted for just a button, or buttons. It should get you started anyway.
pimoroni-pico/buttons.py at main · pimoroni/pimoroni-pico (github.com)
There’s a basic example of how to do stuff with the buttons in our Plasma getting started tutorial. RESET isn’t a programmable button, so you can only use it to cut power to Plasma and restart your program from the beginning, but you could program any of the other three buttons to set all the LEDs to black and (effectively) turn them off.
I forgot the Plasma 2040 had the extra buttons, ops.
This is a better example to look at.
pimoroni-pico/rgb-led-and-buttons.py at main · pimoroni/pimoroni-pico (github.com)