// Short delay to debounce button.
delay(20);
Yes, that will debounce the button but it's going to mess up your LED pattern injecting a 20ms delay like that. Look around for better debounce code using millis().
Your main loop() function ends just after oldState = newState;. Then you have a lot of code which is outside any function. (Use the control-T autoformat to see the problem more clearly.) You should probably delete the } at that point.
uint32_t colorWheel(byte WheelPos) {
byte state = WheelPos / 21;
void startShow(int i) {
switch (i) {
case 0: colorWipe(strip.Color(0, 0, 0), 50); // Black/off
break;
case 1: return strip.Color(255, 0, 255 - ((((WheelPos % 21) + 1) * 6) + 127));
break;
What happened here? It looks like you have a function definition inside another function. I think you need a function which takes two parameters, the WheelPos and the showType. And what does state do? You assign it a value and then never use it.
// Iterate through a whole rainbow of colors
for (byte j = 0; j < 252; j += 7) {
knightRider(1, 16, 2, colorWheel(j)); // Cycles, Speed, Width, RGB Color
}
Yes, it will do that. But the rainbow animation is going to take a lot of time with hundreds and hundreds of 16ms delays. Maybe it takes a few seconds. During that time, you're not looking at the button so pressing it will do nothing.
You need to totally rewrite this section along the lines of Blink-Without-Delay. (Look for it in File->Examples->02 Digital.) Make each call to the animation only advance the animation by one step. Then you need to only call that function once every 16ms and all of the rest of the time you can be checking the button.