I have 11 magnetic reed switches, each connected to 5v and a digital pin set to INPUT. When the switch is closed 5v (through a current limiting resister) will be present at the digital pin. When the switch is not closed, the pin is connected to an open circuit. Do I need an external pull-down resister (connected to ground) to ensure that the pin does not free float but goes to ground when the switch is open?
Hello eric4526
Welcome to the worldbest Arduino forum ever.
No.
You might use the internal pullup resitors of the Arduino using pinMode(PortPin,INPUT_PULLUP); instruction.
Take a view to gain the knowledge:
Have a nice day and enjoy coding in C++.
Use INPUT_PULLUP
and wire the sw's direct to gnd, no Vcc or resistors needed.
Test for digitalRead(pin) == LOW
when active. Wire as S3
Hi, @eric4526
Welcome to the forum.
Why?
There is very little current to flow.
Look @paulpaulson diagram.
Tom..
A reed switch is just a switch - like any other switch.
Sure, you can connect one end to +5V and, in that case, would need a pull-down to 0V.
As the others have said, it's more common to connect the switch to 0V, and have a pull-up.
In that case, you have the added advantage that you can use the microcontroller's internal pull-up - so you don't need to add any external resistors.
See also:
I originally connected the switch that way by using input_pullup and connecting the switch to ground. The problem is that I have other photocells that activate a relay that turns on a magnet. When these relays were activated I would get random digital inputs connected to the switches going to ground. I have tried twisted pairs to the switch and shielded cables and still get random activation. So as a last ditch attempt to get the arduino to indicate the switch closure is to read a high as opposed as a low. Any thoughts?
Good design avoids that problem by completely separating the power ground wiring from the signal wiring. Then making a single connection from the signal ground connection to the power ground connection. That way the signal grounds do not carry the power currents.
Did that. Still got random digital pins activating. I’m going to try the 5v with a pulldown resister and see if that stops the random digital pin activation. Thanks for all you thoughts.
Post some pictures and the schematic of your hardware setup.
My glass ball is still in the dishwasher.
I built a project with reed switches and also found them to be rather unreliable. So I tried hall effect switches. These were brilliant and so swapped to them. The hall effect switches were A3144. Might be work a look at.
Good idea, thanks
FYI. Here was my first test board. You will see the hall effect switches mounted and a magnet to trigger them. I used them for a water level sensor.
Without any further information about his particular setup or usage a reason for having a current limiting resistor in series with the 'loop' would be the extremely low resistance of just a few contacts increases the current draw, so if you lose power to the powersupply/charger and the system is operating on battery backup it can decrease your battery operating time,
Of course it is also directly related to the ampere/hr rating of your batteries.
Hall effect sensors have significant continuous current use - 2 mA or so, see datasheet of your specific sensors. That's a lot for battery operated applications.
Reed switches use zero current when open, 0.5 mA or so when closed (and using the internal pull-ups). This can be reduced by using a weaker pull-up if needs be.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.