Neopixel Mode change with a button

I have changed the program slightly. (I discovered that I was getting the program to check for the button press in the function rather than whilst the function is called! ]:slight_smile: )

It now looks like this:

void loop() {
if(digitalRead(4) == LOW )
{
counter++;
if(counter == 7){
counter = 1;
}

}

if (counter == 1){
// Some example procedures showing how to display to the pixels:
colorWipe(strip.Color(255, 0, 0), 50); // Red
colorWipe(strip.Color(0, 255, 0), 50); // Green
colorWipe(strip.Color(0, 0, 255), 50); // Blue
}
if (counter == 2){
// Send a theater pixel chase in...
theaterChase(strip.Color(127, 127, 127), 50); // White
theaterChase(strip.Color(200, 0, 0), 50); // Red
theaterChase(strip.Color(200, 0, 200), 50);
theaterChase(strip.Color( 0, 0, 200), 50); // Blue
}
if (counter == 3){
rainbow(20);
}
if (counter == 4){
rainbowCycle(20);
}
if (counter == 5){
theaterChaseRainbow(1);
}
if (counter ==6) {
Wheel (20);
}
}

however I have the problem that you stated in that the button press is not recognised until after the loop is finished. Is there a command that would mean that the button press forces the loops to exit?