Nearing the end of my first daisy seed project, and I’ve essentially used all my digital GPIO pins (go big or go home LOL).
A few of the GPIO pins have an SPST on/off mini toggle and, if it’s possible, I’d like to light an indicator LED when those switches are on.
Is there any way to wire in an LED on those switches without using another pin?
Apologies if this is a silly question!
Yes, you can wire an LED and a resistor (around 1k) to a pin - it probably won’t affect sensing and I don’t know what size your pull-up or pull-down resistors are. You can either source or sink current (LED on for high or low).
There is a section of “TTL Cookbook” by Don Lancaster and I think you could find many good websites on the subject of interfacing microprocessors or logic and LEDs and switches for more info-details.
So, I got it working as follows… is there anything about this that doesn’t sound right? As I said, it works, but I don’t know if I’m putting current where it may cause an issue…
- SPST goes to the GPIO pin and to ground
- On the same GPIO pin, add a Resistor then LED (Cathode short leg) and place the anode (long leg) into the voltage rail.
- Voltage flows to the LED when the switch is on and voltage flows to ground when the switch is off - aka the LED lights when the switch is turned on and we only use one GPIO pin.
That sounds fine from the description. You could share a schematic or photo of the circuit just in case, but if nothing is smoking then it should be fine
If you do run out of pins again in the future, please consider using a multiplexer. I made a guide on it: Cd4051 Multiplexer Tutorial Is Here!
You can use it for digital out as well. And it works with any of the programming languages as well!
And feel free to share a video/photo of the project when complete! Looking forward to checking it out.