I have to use the Grove push button on an Arduino digital pin whose pinMode is set to INPUT_PULLUP.
Then I get this:
- when nothing is connected to the pin, pin’s state is HIGH
- when the push button is connected to the pin and not pressed, the state of the pin is LOW.
- when the push button is pressed, the state of the pin is HIGH.
But then, there is no way for me to know if the pin is HIGH because nothing is connected or because a push button is connected and pressed.
If I use INPUT instead of INPUT_PULLUP, then I have:
- nothing connected to the pin, pin is LOW
- push button connected but not pressed, pin is LOW
- push button connected and pressed, pin is HIGH.
Then I know that when it is high, it is because there is something connected and it’s HIGH.
So it works but when nothing is connected, I take the risk of a floating pin.
Any workaround?
Is it because there’s a resistor on your push button board?
Thanks for your help.