I would try adding a 0.1uF capacitor between Gnd and +5V where the wires go onto the breadboard (near the link marked 35 on your photo). I suspect that hitting the switch is sending a jitter into the power line which is upsetting the processor.
I would try adding a 0.1uF capacitor between Gnd and +5V where the wires go onto the breadboard (near the link marked 35 on your photo). I suspect that hitting the switch is sending a jitter into the power line which is upsetting the processor.