I am trying to build a little lamp for a mini desk that I'm creating.
It's built with a LED and I would like it to remain ON also when the button isn't clicked, like a normal lamp.
The fact is that I would really like to not use an Arduino only for this little little piece of my miniature of my room, so: is there a way to let the led stay ON also if the button isn't clicked? Thanks
Sounds like you are using a momentary pushbutton as a switch. You need a latching switch, most likely a toggle switch. Or a slide switch. They do make latching push buttons, but clearly yours is not.
Oh, I understand. Can you link me a button like the ones that you spoke about from the Arduino Store?
I found this Grove - Button (P) — Arduino Official Store but I think that it's a different thing...
..and this https://store.arduino.cc/33mm-arcade-game-push-button-green
I sure can't find one on the Arduino Store. It's does not seem to be searchable, and is not a very good place to buy things like that.
Try Sparkfun for starters: Search Results for switch - SparkFun Electronics
Here is an example of an latching pushbutton: Metal Pushbutton - Latching (16mm, Blue) - COM-11972 - SparkFun Electronics
I hope this gets you started. You can always read up on switch types so that you know what to look for.
Thank you! One last question: how do I connect it to the led and the battery? It hasn't only 2 pins
I call it a "push-on push-off" switch. But "pushbutton on-off" or "pushbutton on-off latching" also seem to be common descriptions. Obviously, if it says "momentary" that's not what you want.
Thank you! One last question: how do I connect it to the led and the battery?
The battery, LED, current-limiting resistor,* and switch all go in series. When the switch is on (closed) you have a [u]complete circuit[/u], current flows and the LED comes-on. When the switch is off open) the circuit is open (or "broken") and no current flows.
- LEDs are non-linear so you need some kind of current-limiting or current control. We normally just use a resistor with "regular little LEDs". With "high-power" LEDs (1 Watt or more) we usually use a constant-current source (not easy to build).
I also found this one, but it has 3 pins: Voltage, Ground and....?
Just use the middle pin and any of the other pins. The middle pin is the wiper, it will connect to either of the other pins depending on which position it is in. Note that it is a three position switch. In the middle position the wiper connects to nothing.
Hook it up, and if the switch seems backwards to you move the wire on the outer pin to the other outer pin.
Wait wait I didn't understand the most part of your post. Keep in mind that I don't know English very well
Can you draw a little circuit? I will use it only for ON and OFF
Give me some time. I'll draw a picture for you. I am at work so I will work it in.
Thank you very much!
Typically the switch pin to use will be opposite of the position of the rocker, so if you view your switch as I show it to the right the LED would be on. Note that the resistor could be on either side of the LED, so if your circuit is a little different that's not a problem.
Still don't understand why there are 3 pins, but thank you very much for te draw!
It's a selector switch. Perhaps you have two leds. One wired to the left terminal, the other to the right terminal. When you flip the switch one way the left led is on, the right is off. Flip the switch the other way and the right led is on, and the left is off. If there is a middle position both would be off.
Switches like this can be used for selecting High or Low, or routing power to different circuits.
It's like and extra switch thrown in for free, use if if you like, or not.
You could use it to select different resistors for your lamp, for dim and bright for example.
Oh ok, thanks