# Indicating 3V3 and 5V with 2 LEDs

I am building 3V3/5V source for my breadboard. The actual voltage will be selectable by the switch. I would like indication, which voltage is actually selected by lighting green LED for 5V and yellow for 3V3. Treshold for 2N7002 is like 2V, so my idea is like that:

simulate this circuit – Schematic created using CircuitLab

But there is problem, that both LED would be lit on 5V, can I somehow simply cut off the yellow (3V3) LED when the green one (5V) gets lit?

Is this schema valid (maby after some resistor adjust)?

Thank beforehands

EDIT: it is just small part of testing environment, meant to anable by jumper 5V or 3V3 output on VCC (or none, if jumper missing). There will be more such device on one PCB and there will be jumper array to configure each, so I would like indicate, what is actually on which VCCxx.

Mode of operation: set jumpers, switch power on, do something, switch power off, reconfigure all the thing, set jumpers ...

It is also possible, that the jumper will be off (SW1 not connected here) and the VCC would be else not connected, or externally driven to 3V3 or 5V. Those internal sources would be on anyway (and would provide power).

So desired result is:

• VCC around 5V (say 4.5-5.5) = green led on, yellow off
• VCC around 3V3 (say 3.0-3.5) = green led of, yellow on
• VCC unconnected or around 0V (say 0-0.5) = both leds off
• either google window comparators or use spdt switches – PlasmaHH Apr 11 '17 at 10:59
• @PlasmaHH ...or have M1 short M3's gate to GND...problem solved (that part, at least...since as Olin Lathrop pointed out, using Vgs isn't exactly a graceful way to set thresholds) – Robherc KV5ROB Apr 11 '17 at 11:05
• @gilhad: Just use a two-contact switch. That's still more unlikely to fail than any circuit. Or use an analogue meter. You can also see if something is fishy with your sources then. Pro-tip: Use a second analogue meter for checking the current. – Janka Apr 11 '17 at 11:48
• the switch is planned to be done as one jumper in a row (so jumper is not exactly what I would like) set first, then the whole is powered and stay that way, then everything switched off and reconfigured. So there are more possible states VCC=5V, VCC=3.3V, (switch unconnected and) VCC=unconnected, or VCC=3.3V externally or VCC=5V externally supplied. I want to use it for fast prototyping (as small as possible), with all multimeters around and so, but have simple indication, how it is configured just right now. – gilhad Apr 11 '17 at 12:12

If I was doing a discrete implementation, I would not use mosfets as switches like that. I'd use standard transistors and a couple of zeners to set the thresholds and tie back the 5V Led drive to kill the 3.3V Led when on as shown below.

simulate this circuit – Schematic created using CircuitLab

• Can I ask, why normal transistros are better? My teory was, that as it is (nearly) static and those transistors are suppose change state only once when it is powered (so say 10x a hour at peak), than mosfets are better, as they do not need current thru base and resistors can be high (as speed does not matter too), so only one LED (20mA/5V max) would eat power. Here the dividers take as much too. (I know, it is not so much, but I am curious) – gilhad Apr 11 '17 at 19:45
• @gilhad MOSFETS have a more linear transition with gate voltage. Transistors are more switch like. Neither are really great switches though if you don't use fast changing inputs. – Trevor_G Apr 11 '17 at 19:55
• It is just power source (or better its end part) for breadboard prototypinig, so it is not critical here. It will be charged from wide range of sources, but usually from wall outlet, so it may happen, that the transformator will waste more energy, then the tested circuit as whole. But I like to know more, if I meet anything uncler to me :) – gilhad Apr 11 '17 at 20:06
• @gilhad ULN2803AG is a darlington array with a significantly higher turn on voltage. Not really suitable for this application. Perhaps find a dual NPN transistor instead. – Trevor_G Apr 16 '17 at 16:10
• I tried, what I had at home, main problem with ULN is that output does not go low enought. Now I found some universal PNP (BC547) and output dropped to about 0.1V at base 0.7V (and depends on input current) - much better :) Anyway my multimeter have so low input resistence that those results are just guess - I will try Arduino ADC, should be better. Anyway I need Shottky diode, as normal has high Forward Voltage and is not able shot down transistor - Anyway I am glad I make all those mistakes, as I learned and understand much more, than from just following working schema blindly. Thanks again – gilhad Apr 16 '17 at 19:36

First, using the gate voltage of a 2N7002 as a voltage reference is not a good idea.

A TL431 could be used since it has a nicely defined threshold of 2.5 V. You can use two. One is set to turn on at 3.3 V (taking all errors into account), and the other at 5 V. You could use a lockout so that when the 5 V circuit triggers, it turns off power to the 3.3 V LED.

• Maybe I'm not fully awake yet, but I think this answer could really use a schematic. – Tut Apr 11 '17 at 11:15
• There's an example on page 28 of the TL431 datasheet. Related answer – try-catch-finally Apr 11 '17 at 11:48
• @OlinLathrop: Took me some time to understand, why it is not good idea, but you are right - I was only aware to bring "enought volts to sure open" there (if the VCC is 3V3 or 5V), but I also need to bring "low enought voltage to close for sure" to 5V if VCC is 3V3 - and it is not ensured this way. The tolerance of threshold is really wide. Much more, than I thought. – gilhad Apr 11 '17 at 19:57

A better way would probably be to use comparators instead.

simulate this circuit – Schematic created using CircuitLab

I can't be bothered to do all the math for you, so left all the resistors as their default values. But you just set it up so that when it is a 5V supply, OA1 turns its LED on, and when it is a 3V3 supply, OA2 turns its LED on.

Shouldn't be too difficult to do it like this. Although, bear in mind I am still learning electronics myself so other people may well have much better solutions than me, but this is my suggestion! I have done this myself before so I know it works.

• R2 should be removed from this diagram...comparator 1's non-inverted input & comparator 2's inverted input should be "shorted together" if you want their outputs to complement each other ;) – Robherc KV5ROB Apr 11 '17 at 11:38
• Ahh fair point. I'm sure when I done it I had a resistor there anyway! But yeah, I suppose it's not really needed! – MCG Apr 11 '17 at 11:40
• in an analog circuit, it would cause overlap voltages where both LEDs would be illuminated. However, for this particular circuit, with only 2 likely values for Vcc, as long as you didn't make R2 too big, the overlap wouldn't matter, as the voltage should never be in the "grey area" it creates. – Robherc KV5ROB Apr 11 '17 at 11:43
• Oh I see! Thanks for that, always appreciate new knowledge! – MCG Apr 11 '17 at 11:44
• Also, it's generally best to use a transistor between any load and ground for switching, rather than using the output of a logic circuit to directly drive a load. In this case, a single indicator LED is hardly likely to overload the circuit, but it can be a costly habit to get into (trust me, I've blown up a couple). Having the comparator drive a transistor instead of the load directly limits the current drawn from its output, and can save you \$ and frustration later when you attach a load that pulls "1 mA too many" from a logic device (either kills it, or causes malfunctions) – Robherc KV5ROB Apr 11 '17 at 11:52

I think this circuit will "fill the bill."

The zener diode is set to 3.3V.

When the VCC voltage rises above about 4V, the comparator output shifts HIGH, "turning on" M1, which allows current to flow through the green LED and shorts the gate of M2 to (one diode drop above) GND.

Conversely, when the voltage drops below 4V, comparator output shifts LOW, "turning off" M1, which raises the voltage potential at its source to nearly VCC, which passes to the gate of M2, allowing current through the yellow LED.

simulate this circuit – Schematic created using CircuitLab

• Another option would be to drive the gate of M2 through a "NOT gate", or "Inverter" connected to CMP1's output. ... really the same thing, just that I used the led+current resistor and M1 to form my own inverter/NOT gate here. – Robherc KV5ROB Apr 11 '17 at 11:34