# How to create an on/off indicator for a SPST in a circuit?

I've recently started to work with electronics and I'm truly a beginner. Our teacher asked us to create an on/off indicator for a SPST button in a circuit. When the button is pressed the green light should glow, and when it is released, the red light should glow.

How would I do that?

• The green light should be simple, for the red light you need what is called a "not logic gate". A google search will give you examples how to build one (there are different ways, but for your application it does not really matter what you choose). Commented May 22, 2015 at 7:46
• What things have you used up to this point in your course? It would help us in guiding you to an answer. The folks here can come up with all kinds of answers, but they may be entirely unrelated to what your teacher is trying to get you to learn.
– JRE
Commented May 22, 2015 at 10:03

This circuit will work regardless of the type of SPST switch

With the switch closed a current will pass through LED1 and R1 and turn the green LED ON indicating the switch is closed. R1 is chosen to limit the current through the green LED. In this case 1k0 will limit the current to about 7mA ((9 - 2)/1000).

This will also produce a voltage drop of about 2V across the green LED. R3 and R2 divide this voltage drop so that at Q1 the base - emitter voltage will be less than 0.6V (= 0.35V). The transistor Q1 will be turned OFF. If you find the transistor is not turned off you can always lower the value of R2.

As Q1 is OFF no current can flow through Q1 and the red LED will be OFF.

When the switch is OPEN no current can flow through the green LED so it is OFF. The base of Q1 is now connected through R1 to ground. The voltage at the base of Q1 is sufficient to turn the transistor ON (0.6V). Current now flows through the transistor Q1, R4 and the red LED which now lights up indicating the switch is open.

# Straightforward vs inventive solution

I will use my answer not only to solve the OP's problem from seven years ago but also to show the difference between a straightforward and inventive solution. The former is based on the use of a standard NOT logic gate while the latter is based on some unexpected circuit trick. I had the chance to come across such a clever trick 40 years ago (see my paper and my answer), and now I am going to use it to solve the OP's problem. This once again shows that ideas are eternal and immortal; only their implementations die. That is why it is important to see the ideas behind circuits.

# The inventive idea

The trick is very simple but significant because TTL and ECL gates are built on it. It is known under the name "current steering" and is based on the following: if we connect two diodes with different forward voltages in parallel, the current flows through the diode with the lower voltage.

# Implementation

In this case, this means that if we connect a (green) LED with a lower forward voltage to a lit (red) LED with a higher forward voltage, it will turn it off. And since red LEDs usually have a lower forward voltage than green ones, we can artificially increase it by connecting an ordinary silicon diode D in series (a trick widely used in TTL gates).

# Operation

## The button is OFF

Current flows through the red LED and it lights up. The total voltage across the string of two diodes is about 3V (I have connected the voltmeter only as a voltage indicator).

simulate this circuit – Schematic created using CircuitLab

## The button is ON

The green LED is connected in parallel to the diode string and sets the total voltage across it about 2V. As a result, the current is diverted through the green LED and the red LED turns off.

simulate this circuit

# A straightforward solution

simulate this circuit

simulate this circuit