Hi Trace!
Oh man, I have no idea where the days seem to go. Almost a week later now .... and I really meant to reply right away.
And yes: normally one would pay to have less problems. If I only could find a more reliable forum for Wordpress. 😞
First thought that popped in my head is by using global variables for the color definitions, and use an interrupt (when a button is being pressed) that calls for a function that changes these global variables. Since the effects reads these global variables, instead of the passed on parameters, the change should be visible almost instantly.
So basically you'd define something like this in the beginning:
...
#define PIN 6
const int Coin_button_Pin = 3; // the number of the pushbutton pin
int buttonState = 0; // variable for reading the pushbutton status
...
// option 1: use CRGB
CRGB effectColor;
// option 2: use 3 bytes
byte effectColorRed;
byte effectColorGreen;
byte effectColorBlue;
Using CRGB seems more appropriate, but using 3 bytes works just as well and may be easier to understand and work with - depending on your preferences and experiences.
The interrupt can be set, like I've done in the second LED Effects project.
It works something like this, where BUTTON is the pin number used for your button, and "changeEffect" the name of the function that is being called when the button is pressed:
void setup()
{
... // first your usual setup steps
pinMode(2,INPUT_PULLUP); // internal pull-up resistor
attachInterrupt (digitalPinToInterrupt (BUTTON), changeEffect, CHANGE); // pressed
}
The change function could look something like this:
void changeEffect() {
if (digitalRead (BUTTON) == HIGH) {
// change colors here to something, for example:
effectColorRed = 123;
effectColorGreen = 123;
effectColorBlue = 123;
}
}
You'll have to play a little with this to see how well this does, or does not, work.
There are most certainly some downsides to using interrupts like this, and also keep in mind that an Arduino was never designed to do some sorts of multitasking.
Having said that ... multitasking can be addressed by multi-core hardware like the ESP32 (cheaper than an Arduino, yet compatible with an Arduino, powerful, comes with more memory, more speed, wifi, etc - an article on how that works).
I've played with its smaller sibling, the ESP8266, for a bit and have to say: I'm very impressed and I'll probably never buy an Arduino again. I have an ESP32 ready to play with, but it's been laying on my desk for almost a year now. Just not having enough time in a day to get to it 😁 -- but I'd be willing to explore it together now that I have even more motivation
Anyhoo - let's see how well Interrupts work for you first 😊