Controlling RGB LED strip with multiple states

Just a quick description of my project: I compete in a robotics competition known as FRC. The robot itself is programmed in Java and provides a number of inputs and outputs, none of which work particularly well for controlling a strip of individually addressable RGB LEDs. As such, I am using an Arduino with the FastSPI? library that handles a lot of those issues for me. I had also been interested in running multiple "states" which are basically just patterns that the lights show. I solved this by adding a switch and having a case for each state and to select my case I used 4 Digital Input pins which are turned into a binary string and into an integer for easy processing. This works fairly well, the main issue I've had is that each "state" is separated into a for loop and the switch to go into each state is in a while loop where the pin information is checked at the top. This means that the only time that the current state can ever be changed is when a state has been completed so that it has been brought back to the top of the loop. This is not satisfactory as I would like for the state to be able to be changed essentially on the fly. I know very little about the internal workings of an Arduino or of the language that is used to program it other than that it is C-based. I am using an Arduino Uno. I have multiple years of programming experience in multiple languages so if you can just push me in the right direction I should be able to figure out a solution on my own.

Thanks for your time, Eddie

Shameless self bump

This is often solved with a state machine, although the switch statement is the core of the FSM, so you're possibly on that road already.

A simple solution would be to have your for loop condition check the digital inputs to ensure that the state is unchanged.

More elegant would be for the state to do only one iteration of its pattern at a time so that the check for inputs happens more frequently. If you're using delays, they will need to go.

Post your code for more specific advice.