Sanity check on wiring a tactile button to a digital pin

Can someone just sanity check I have these tactile switches wired correctly, pulldown to ground when open and 5v when closed?

Hi,
Yes that configuration is fine.
Just make sure you check the pinout configuration of the tactile button.

Tom.. :grinning: :+1: :coffee: :australia:

Highly, highly recommend you not wire switches like that.

Wire switches as S3 is wired below.


Hence, your switch should be wired as below.


A switch wired as above will give a LOW when the switch is closed/pressed.

Looks good, but you can simplify the circuit by using the built-in pull-up resistors and wiring the switches to ground to pull down when closed. It will reverse the buttons' polarity though.
See tutorial here: https://docs.arduino.cc/tutorials/generic/digital-input-pullup

Its "correct" - but unsafe. As @LarryD has indicated.
There are many good reasons to use a configuration with the switch to GROUND and a pull-up to Vcc.
More here

Or see this explanation

http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

Yes. I've been using real pull-ups since I was pulling anything, mostly now out of habit but there is this from @Grumpy_Mike's linked article:


So would you ever want to use an external pull up resistor when there are internal ones fitted? The answer is a yes, this is because the internal pull up resistors are only weak pull ups, that is the value is about 30K and it is not so strongly pulling up.

Since I'm not making 10000 of anyhting, I don't care about a few extra parts and although using a real pullup resistor is not the reason, I sleep very well when I am asleep.

a7

Yes those comments were about inputs in a strong EMI environments or from devices that are a long way away. But the normal internal pull up resistors are fine for push buttons within about a foot away from the processor.

Normally you should choose to connect your switches to the ground rail.

Why? because if power is removed from the Arduino a pin that stays connected to a positive supply can allow current to flow and damage the circuit.

Thanks for the link, that's a failure mode I never thought of -- though in retrospect I should have :sweat_smile:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.