Hello There!
Im quite new to arduino, and need some help. I purchased 12v push buttons that have LEDs. I have 4 connection pins. Button + & -, and LED + & -. I know how to wire the button but no clue how to wire the LED to arduino. Could anyone help me out?
Thanks!
Please post a link to the datasheet of that button.
Here you go: https://a.aliexpress.com/_m0IEUD6
The buttons were purchased from a Chinese manufacturer, so not many specs
Welcome to the forum
The button is either side to arduino pin and the other side to ground. The led is positive to 12v supply and negative to ground. You switch the supply with appropriate circuit but depends what you want the LED to do. Set arduino pin to input pull-up for button. Use a multimeter if you have no data sheet to make sure the led has appropriate resistor for 12v supply. It tends to be easier to switch the negative side of the led and you can use a io expander to control multiple LEDs IR you have a lot of them
What is your project
I want it so that when you click the button, the led turns on. Obviously
So would that mean that I would have to connect the Led + to 12v supply and then to the arduino digital pin via a resistor?
No, the arduino does not do 12v. You need to use an electronic switch such as a mosfet, transistor etc or an IO expander chip that can drive LEDs. Depends on your project and it is not “obvious” as the combinations are many and varied. Since you continue to give no information on your project we must guess your intentions. Eg do you want the led to come on when you press the button and then remain on? Or remain on until pressed again? Or remain on only as long as the button is pressed, or remain on until some action is finished (like an elevator reaches its stop) etc etc etc. does this interact with other things in your project or is it just a random button led for fun and experience?
Since we don’t know your project or your requirements then I suggest Google.
Ah sorry ! didn't see the full message....
Yes it's an elevator project, hence why i purchased buttons that look like an elevator. Yes, i want to click the button, led stays on until the elevator reaches its floor and then turn off again.
Just the one button? Which arduino?
A logic level mosfet will do the job. Source to negative 12v, gate to arduino pin, drain to negative led. Resistor from gate to pin and pin to gnd
I have 5 buttons, all will be working together (hopefully)
Arduino Mega
Do you want to make your own solution as @pmagowan has suggested or do you want a module to handle the LEDs on the buttons?
If the former, FQP30N06L (must have L at the end) is a good choice or you can get IRF520 MOS modules that can do the same thing, but pricey (as the price of convenience usually is).
You can drive your LEDs directly from the Arduino as explained here
just because they are "12V" buttons doesnt mean they NEED to connect to +12V.
However since we dont know what will be connected to them ...
You can drive them direct from the arduino but they won’t be very bright if they are the type I have used. They have already got internal resistors for an expected 12v to the LEDs so the 5v or 3v3 of an arduino is not great. I drive mine with a PCA865 and a Darlington array.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.