Question about pulseIn

When you push a button you often get a small set of pulses before the button stays in the on condition this is know as bounce.

The state of the button goes from off to on to off to on to off before it stays on.

pulseIn (as used in your code) will only report the first of these bounces.

Mod your code so that it ignores any pulse that is less than say 100mS and you should be OK.

Mark