using either a rotory encoder or button press count to change pwm mode

If you're using that array with that for loop, you're using pin zero twice.