I want to use the LED for communication about the state.
So in normal mode it is on, and then when a time out is closing, it starts flashing.
I’ve gotten the code built.
But the question is, can I drive the LED in the button directly from the GPIO? Do I need to put a resistor on it, or can I use a built-in pull-down or something?
I’ve previously had a relay on it, but I would like to save some space from that.
If you have a button with a 5V LED, it is possible to connect it directly to the GPIO. The only problem I see is that if the LED is powered by 5V, it already has a limiting resistor inside and the GPIO output is only 3.3V. The LED will glow dimly or not at all. I would probably use a 3.3V/5V level converter.
Can you share the LED flashing code?
I don’t really understand the description of button 3 - 9 (5V)
@pepe59 could I use a MOSFET? I’ve gotten some lying around P16NF06L, but I’ve no idea how to connect them (I’m not that experience with components, except for soldering them together).
Yes you can. This MOSFET has a threshold voltage (VGS th) of 2.5V, so it will be turned on by the 3.3V output of the GPIO.
Connect the GPIO pin to its gate, the source to ground and the drain to the shorter pin of the LED. The longer pin of the LED should be connected to a 5V power with a resistor in between to limit the current flow (else the LED will burn itself). That should be all. Whenever the GPIO is high the MOSFET will short the drain and the source so the LED will turn on.
@pepe59 Hmm, I can’t find my order for the buttons on banggood any more, they were ordered years ago, and if I try and measure resistance across the diode, my multimeter just says no connection, so I guess I’d better go with a resistor.
I have a couple lying around in a heap of mess, as far as I can it’s a 33 Ohm and 110 Ohm, so I guess they are too small, right?
If there is a standard LED diode inside the button, the diode should have approx. 2V, current 20mA and input voltage 5V, the limiting resistance will be 150 Ω.
I still don’t believe that there is no limiting resistor inside the button.
Just verify by connecting the LED button to 3V(pay attention to the polarity of the LED +/-) and if the LED lights up weakly or at all, connect it to 5V and if it lights normally then the button contains a limiting resistor. It can also be checked with a multimeter, but measure the LED in the forward direction.
The link to the buttons is that the LED switches on only when the button is pressed