Go Down

Topic: detecting a switch (Read 546 times) previous topic - next topic

zarobhr

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

CrossRoads

Turn on the pin4 internal pullup resistor.

pinMode (pin4, INPUT_PULLUP); // IDE 1.0.1

pinMode (pin4, INPUT);
digitalWrite (pin4,  HIGH); // earlier IDEs
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

zarobhr

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

dc42

Do you have a ground connection between the reader and the Arduino?
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

zarobhr

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??

dc42

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.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Go Up