detecting a switch

i have connected a magstrip reader to my mega2650 i can get it to read most of the time
one of the inputs it use is card detected.
in my test proram i have led 13 lighting up when the input (using pin 4) detects the card in

when a card in inserted into reader it grounds that pin

the problem is if i move my hand close to the reader it will trigger that pin 4 input.

what can i do to the connection at pin 4 to keep the interference out and ensure it only detects when the switch is pushed

thanks in advance

Turn on the pin4 internal pullup resistor.

pinMode (pin4, INPUT_PULLUP); // IDE 1.0.1

pinMode (pin4, INPUT);
digitalWrite (pin4, HIGH); // earlier IDEs

just tried that and still same issue even just touching my finger on the plastic of the connecter triggers it

Do you have a ground connection between the reader and the Arduino?

yes there is a ground going from the arduino (next to 5v pin) that goes to card reader, at the card reader that ground feeds 2 switched and a chip,

do i need a separate ground to the metal frame of the card reader as well??

If the metal frame isn't already connected to the card reader ground inside the card reader (which you can check with a multimeter), then try grounding the metal frame.