having a "script" pretty much run when button pressed?

How could I make it so when one of four buttons is pressed a “script” pretty much runs of what I want to happen. So I want each of the 4 buttons to have its own script that runs when pressed and the other buttons are locked so if you press them while one script is going all buttons are disabled until the script finishes

So I would like to have different “light shows” happen when different buttons are pressed with 4 WS2812B individually addressable Leds and 4 buttons. I would like it so when no buttons are pressed the Leds are yellow, but when one of the buttons is pressed the led corresponding to that button turns green while the other ones turn red for 10 seconds and then the red ones go off and the green one goes blue and flashes for 5 seconds and then they all go back to yellow waiting until another button is pressed.
I was able to get multiple buttons wired up and they all went through a single analog pin and when held down certain Leds out of a row of 7 would light up and different ones would light up corresponding to what button was pressed but I’ve tried for a few hours trying to find how to make a button start something and then have RGB Leds do different things but I can't seem to figure it out.
I’m just starting to get the hang of coding and I still have to look at other people’s example and piece it together to make my own

How could I trigger something like this with 4 buttons and an Arduino?
thanks! :slight_smile:

One approach is to have four functions, each one called when a particular button is activated.

Example.

if (button1) function1();

"button1" might be set true in the loop() function, after button 1 is pressed and then released. You might need to come up with some condition to terminate the function, unless it terminates automatically after a series of operations.

Of course you cannot use delays if you want the buttons to be responsive.

What you can make it do is limited by what code you can write.

Your sketch only does 1 thing at a time that I can see. You only watch the button pin when the colors are not changing.

I was able to get multiple buttons wired up and they all went through a single analog pin and when held down certain Leds out of a row of 7 would light up and different ones would light up corresponding to what button was pressed

Maybe start by posting that sketch inside of code tags shown in the sticky thread How to use this forum - please read.

Code tags look like [code] [/code]. Code inside will not be interpreted as html and print funny.