Problems with push button / LED button connection and reading on Arduino

Good afternoon.

It's my first forum post so I hope I don't sound too new.

I have bought some buttons for a 'children's' home automation project for my children. It turns out that the connections it brings are NC, NO, C, LED and A. For thousands of pages (including the one on Aliexpress where I bought them) I have 'found out' that NC is Normally Closed, NO is Normally Open and C is Common. But from there, the information is very, very extensive, and I don't quite get it.

My idea is the following. I want the buttons to be permanently on, and to be able to know when the buttons are pressed in order to control project actions. And what I don't know is how many cables I have to connect to which pins, which to ground, which to 5V (they are 3.3 to 6V buttons, I can take the 5V output of my Arduino), and above all, how is the code that I have to implement.

I'm not clumsy with the code, but I have read various things about INPUT_PULLUP, about how I have to start the pins ... and I am very lost right now.

Attached photo of one of the pushbuttons from behind.

Thank you very much in advance, and I hope I can help with something else when someone is as lost as I am ...

How to post an image

Hello tekieiya,
Push buttons with both NO and NC contacts are unusual. The normal way to wire a button is to use NO contacts, which in your case means the C and and the NO contact, ignore the NC contact, and connect between an input and ground, so one contact to ground, the other to the input, ignoring NC. Doesn't matter which way round. Use INPUT_PULLUP. Study the examples in the IDE, especially under 02.Digital study the top 5 examples in particular.

Yes what Peter says is true. If you want a walk through of the reasoning see:-
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

If you don't understand anything then please ask a specific question.

Thank you very much for the replies!

I will read all that documentation and I hope that no more doubts arise.

tekieiya:
It's my first forum post so I hope I don't sound too new.

Actually, your second as your first was in Spanish. :grinning:

OK, what you need to do now, is to show us the Website (URL) with the details of this pushbutton.

More to say later.

The web is

Thank you!!

Which, of the many buttons on that web page, is the button you have bought?

If it's the one I think it is then it has an LED in it, which is why it has 3 terminals, or maybe it has 5, I am not sure.

It would appear to be this one:


with this 5-pin pinout on the right:

Because it is indeed a SPDT pushbutton.

Unfortunately the diagram Selection_036.png is not actually helpful as you have to know which end is up but the actual switch is marked "LED" for the cathode (negative) and "A" for the anode (positive) of the LED.

Now what to do with it depends on what the OP has muddled in the description - you connect the common "C" to ground and "NO" (normally open) to the Arduino input pin using INPUT_PULLUP.

What you do with the LED depends on whether you want it always lit, lit when (but only when) the button is pressed, or controlled by the Arduino. It is not specified, but likely that the LED will take no more than 25 mA, within the capability of an Arduino pin to drive, but this should be checked with your multimeter.. :grinning:

Selection_036.png

Really clear, thank you very much!!

I will check this and tell you!