Can I Wire Button Directly to the Arduino?

Is a bread board necessary or can I wire a button to the Arduino with the built-in resistor?

Yes. Wire the button/switch to ground and enable the built-in pull-up resistor.

The resistor pulls the input high until the button is pushed. The button "overpowers" the resistor, pulling the input to ground (and current flows through the resistor).

Here is a schematic showing a pull-up resistor and pushbutton switch. (With the internal pull-up enabled, of course you can leave-out the resistor and just connect the switch.)

Pull-up Schematic

Probably a stupid question, but why does the switch have 4 legs but only 2 inputs cables connected, does it matter what input a connect to each leg?

That depends on the way the switch contacts are configured. For example, this pushbutton only has 1 "switch" inside it but 4 pins.

image

2 of the pins on each side are connected together internally.

Can you upload a photo of your switch or provide a link to where you bought it from?


These switches, I don't have a link as they are from my school

With that type of pushbutton, usually 2 pins on each side are connected together internally so it doesn't matter which of the 2 pins you connect to. But make sure you are choosing 2 pins that actually are on opposite side of the switch contacts otherwise it will always appear the switch is closed!

For example, here is a section of the datasheet for an Omron tactile switch:
image

Look at the terminal arrangement image in the lower right hand corner.

If you use two pins at diagonally opposite edges, you are on the safe side.

Also, I soldered this together to split 5V and GND pins (I made multiple) would this work?

The voltage would flow the wrong way or only go to one pin/component right?

Just to be clear, looking at the photo, you have 1 pin (bottom of the photo) and you have a mixture of pins and sockets (top of the photo) and you have soldered them all together (join in the middle of the photo)?

If that is correct, then whatever voltage is applied at one pin (or socket) will appear at all the others.

I have several similar to yours but 1 male pin to several female sockets.

Be careful if you have exposed pins as they have a mind of their own and will often touch delicate electronics causing irreversible damage.

Thank you, I will be very careful.

  • You can make a simple bus bar if you use an IDC connector as seen below.

BTW

  • To prevent shorting, you might want to use only female connectors.
    If needed, add a male header pin to change the gender.

1 Like

The main purpose of the 2 "unused" legs is:
!: Feed through, common wire or trace of one button to common of the next.
2: Stability on circuit board.

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