and each loop has a statement such as:
void rainbow(uint8_t wait) {
if (counter == 2) {
uint16_t i, j;
Seems backwards to me.
if(counter == 2)
rainbow(20);
seems more straightforward.
I suspect that you want to increment counter when the switch BECOMES pressed, though, rather than when the switch IS pressed. Look at the state change detection example.