Arduino not counting button presses correctly

Hi all, my problem is that while the button is pressed the arduino continues to count presses, so if the button is pressed for say four seconds the arduino might count 40 presses.

My setup looks like this, the button is actually a relay inside a "photosensor", the relay is closed, and input goes high, when someone passes a sensor. I have installed this setup in a store with three sensors, one works fine but two others exhibit this problem. So when one person passes the arduino might count seven.

The sensors are not constructed by me, but they are all identically connected to the arduino.

The sensors are placed roughly 10-20 meters each from the arduino, the signals are transmitted through an unshielded cable, could this be the problem?

is actually a relay

It looks like you are suffering with contact bounce. A relay is susceptible to this kind of thing. The contacts make a series of rapid transitions as they close. The trick is to debounce the switch see:-

Thank you, I will try this tomorrow and report back.