2

I made a small circuit in which a push-button is connected to Arduino via a pulldown resistor. So, whenever it is pressed it connects to 5V otherwise pulled down to the ground. this is working fine but I wanted to know is there any way to detect whether the push-button is connected to the circuit or not? In case if push-button disconnects from the circuit, how to detect it?

asked Oct 1, 2020 at 16:41
7
  • 1
    resistor across the switch ... use analog input Commented Oct 1, 2020 at 16:46
  • no ... it would produce a voltage level that is dependent on the state of the switch Commented Oct 1, 2020 at 17:21
  • 1
    another way would be to remove the pulldown resistor and connect the switch between two data pins Commented Oct 1, 2020 at 17:23
  • 1
    A push-button that is not being pushed is electrically equivalent to no push-button at all. Your Arduino will never be able to tell the difference. Commented Oct 1, 2020 at 18:36
  • Create a dpdt switch that uses two resistors to give different values for the two positions and use an analog pin. Still you have the possibility that the floating input just accidentally reads the same as one of those values so it isn’t very reliable. Commented Oct 1, 2020 at 19:40

1 Answer 1

1

The simplest way, as @jsotola has said, is to put a resistor across the terminals of the SPST push-button and read the voltage using an ADC input of the MCU.

However, the resistor needs to be bonded to the push-button (or inside the push-button housing) to ensure that when, for example, a vandal rips the push-button out of your switchboard, the resistor is certain to go with it so that the MCU can tell the difference between HIGH, LOW, and MISSING as @EdgarBonet pointed out. You also need to consider the continuous current draw of the extra resistor for low power/battery devices. You could increase the resistor values, but that tends towards weak pullup/pulldown. If you increase the value of only the extra resistor, it shifts the output voltage closer to the rail voltage reducing the margin for error.

SPST Push-Button AWOL Detector

Figure 1 – SPST Push-Button AWOL Detector.

Perhaps a better, but more expensive way, is to use a SPDT push-button. This push-button requires no modification, but is more expensive than a SPDT push-button and requires an extra wire and resistor. This circuit draws less continuous current and has stronger pullup/pulldown.

SPDT Push-Button AWOL Detector

Figure 2 – SPDT Push-Button AWOL Detector.

answered Oct 2, 2020 at 13:05

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.