Arduino push button not responding when in line with resistor

Troubleshoot step by step. Put a print statement right after you read the switch to make sure that it is being read.

Put other prints at strategic locations to monitor program flow and make sure that things are happening as you expect.