Studying articles of the site Instructables I found some interesting projects(for example, I liked [this one]), where two LEDs(red and green) are used indicating the sensor's mode (ON or OFF).
Having thought about this problem I found that there is a huge amount of different ways to solve this seemingly simple task.
Today I want to offer to the community as a minimum five different schemes of two-color display that you can easily implement in your DIY projects.
Step 1: Most Common Circute
The easiest way to solve our problem - is to use the switch as a sensor. Really - what could be easier? If one contact group is closed - the red LED lights, and if the other one - the green LED lights.
However, the apparent simplicity of this idea is illusive - it is unacceptable in many projects to use the switch as it significantly complicates the design. five (or more) following schemes will use two-contact switch having only two states: open or closed.
Step 2: Tricky But Simple Circuit
The following circuit includes the same parts as the previous one, but there is other type of mechanical sensor used here - not a switch, but a breaker.
Such a scheme is applicable in many projects (for example, you can use it for testing continuity of electrical circuits), but it has three significant drawbacks:
- high control current (through switch flows a current of ~6mA);
- VCC voltage will be STRICTLY 2.8 - 3.3 V;
- high power consumption during operation of green led (~16mA)ю
Step 3: Decreasing of Control Current
So, we use the previous diagram as a benchmark and try to improve it. The first thing I propose to reduce the current flowing through the sensor. This is especially true if you are not using some high quality factory switch, but a homemade door closure sensor or, for example a [reed switch].
As you can see, I added a transistor in circuit. This approach allows to reduce the current flowing through the sensor up to 0.1 mA and that is a good characteristic!
If you put, out of curiosity, to VCC input of circuit a voltage of 5V, both leds will be simultaneously illuminated, and this is unacceptable (for our problem). Such a deficiency, as you probably understand applies to the previous circuit. Let's try to get rid of it.
Step 4: Increasing of Supply Voltage
The simplest way to raise the supply voltage of circuit, for example up to 12V, is to add one transistor and one resistor. The proposed scheme still has high power consumption when green led is working.
Be careful! Resistors R3 and R4 are designed for a voltage not exceeding 12V! If you want to raise the voltage up to 24V - be sure to increase the resistance of these resistors up to 2kOhm each!
Step 5: Perfect Circuit
Well, I offer your another scheme, devoid of the shortcoming of the previous three ones - it's a bit more complicated and may require little adaptation to fit your specific goals. Non-obvious advantage of this scheme is its higher resistance to electromagnetic noise as compared with the previous two schemes.
Step 6: Bonus Circuit
This is my favorite scheme! Its main advantage is simplicity. The only negative fact - high control current. In some cases, this scheme will even work without resistors R4 (open circuit) and R1 (short circuit)! However, I still recommend to install them (for reliability).
Step 7: Conclusion
Today, we considered six very simple control schemes of controlling two LEDs with a single sensor (mechanical switch). I hope you liked them and, thanks to my instruction you discovered something new. In the end I would like to give some advice:
- In schemes 3 and 4, I recommend to add an additional resistor between the base and emitter of each transistor. I recommend a resistor of approximately 1 MOhm or less. So you can avoid accidental activation of the green LED in the event of an unfavorable electromagnetic environment around the scheme.
- Instead of BJT transistors you can use MOSFET transistors. In this case, the previous advice about the resistors of 1 MOhm is binding.
- If you want to use a superbright LEDs, you will have to change the values of the resistors (R2-R3 in schemes 1,2,3,6 and R3-R4 in schemes 4-5) to lower ones (e.g. 2 times lower).
- The ability to work of schemes 2 and 3 strongly depends on the chosen leds. If it happened that you have both 2 leds working at the same time - increase the values of the resistors R2 and R3 (for example, twice).
P.S. Please do not judge strictly. This article, like the previous three ones are markers for me and based on them I'm trying to understand what area of my knowledge could be the most interesting for the community. If you have any advice for me (e.g. if I should upload much more complex schemes) - be sure to write, I hope to have your support! Thank you!