i have an output pin connected to a magnetic reed switch. The pin mode is INPUT_PULLUP. When the switch is closed, it connects the pin to GND and drags the pin to a LOW reading. I check the state of the pin in the loop function. Occasionally the pin reads LOW when it shouldn't (the switch is not closed) - e.g. around once per second. What could cause this? The wire from the pin to the switch is about 1m long - could this be long enough to intermittently drag it down to a LOW? Also, it seems to happen much more when the air temperature is hotter.

Circuit summary: Pin (INPUT_PULLUP) -> Magnetic reed switch -> GND


1 Answer 1


My guess would be that you're getting noise interference on the line and it's too much for the Arduino's little internal pullup. Try adding an external pullup resistor - say 5k-10k (exact value is not critical).

  • Thanks, you are correct. I managed it through code. E.g i'm now taking 10 samples a second, and to change state it needs 10 consecutive samples to be the same reading. This has been working without fail now for days. I suspect noise can only pull the pin down briefly (nanoseconds?)
    – Shane
    Commented Jan 13, 2017 at 2:39
  • Yes it will be brief, but how frequent will depend upon where the interference is coming from - it could conceivably happen a lot. If that's working for you then it sounds like a reasonable workaround.
    – Mark Smith
    Commented Jan 13, 2017 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.