Pages: [1]   Go Down
Author Topic: detecting a switch  (Read 450 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 77
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 437
Posts: 23662
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Turn on the pin4 internal pullup resistor.

pinMode (pin4, INPUT_PULLUP); // IDE 1.0.1

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

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 77
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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.

Offline Offline
Jr. Member
**
Karma: 0
Posts: 77
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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.

Pages: [1]   Go Up
Jump to: