Simple question but tricky

I have a switch with three positions that switches from the middle pin ground to the outer ones. I want a LED to light up when the switch is in the middle position. But only in the middle position. See (LP 18 has nothing to do with the issue):

I am looking for an elegant circuit with as few components as possible. Does anyone have an idea?

Wire the centre contact to GND, the outer ones to 5V and the common connection to an Arduino pin set to a pinMode of INPUT_PULLUP. When digitalRead() of the pin returns LOW then you know that the switch is in the centre position

You didn't say what you want the other positions to indicate. I assume it's something? Otherwise, one position is a dummy position...

The generic way to interface this and read all 3 positions in software, is to ground the middle contact, each outer contact goes to an input configured with a pullup resistor.

Then, in the "upper" position, the "upper" input is low, the other high. In the "lower" position, the "lower" input is low, the other is high. In the middle position, neither input is low.


0b01 = lower
0b10 = upper
0b11 = middle

In fact, judging from your diagram, this wiring already exists and you only need to interpret "LSP SD" and "Backlight" inputs in that way. Probably, but you should check, those inputs are already pulled high by a resistor.

So the input condition for the middle position is:

(backlight == HIGH and LSP_SD == HIGH)

Sorry, I wasn't clear enough. The switch is already wired that way, I can't change anything. This switches "passive" electronics, the pins do not go to GPIO's, there are also no more free, so a software solution does not work, this needs a hardware solution.

Like a DPDT switch? :slight_smile:

Do you know anything about the Backlight and LSP_SD connections? What voltages/impedances are on there?

One goes to a backlight of a TFT Dsiplay to turn it off and one goes to a sound amplifier to turn it off. Just ground.

Not enough. Measure the current and voltage. Do you know how to do that? If not, I can provide the procedure.

Also please comment on the idea of extra contacts (DPDT). Those operate in tandem and so you could have any independent circuit driving LEDs on a dedicated set of contacts.

The Vbe drop shouldn't prevent the voltage at the switch common from being seen as logic ground. If there's enough current available from both paths this might work:

I think you mean that the middle pin is grounded and each of the others goes to the negative of a component to turn it on. In the middle position neither are turned on and of course both cannot be turned on at once.

If this is the case, you can use something vaguely similar to MarkT's circuit except that you must use a logic-level FET, not a transistor and the gate is connected not to the centre switch contact, but to the anodes of two diodes, the cathodes going to each of the outer switch terminals.

You will also need a 10k resistor from gate to the supply terminal of whichever is the higher voltage.

What is peculiar is that you would ground the negative of an audio device to turn it on. You might care to explain how this works. :astonished:

It looks, from the picture supplied, that your assignment is to connect the 3 pins of the switch to the three solder points marked LP15, LP16 and LP17 in such a way that the switch has the following behaviour.

Position 1: display backlight ON, Alarm (LSP SD) ON
Position 2: display backlight ON, Alarm (LSP SD) OFF
Position 3: display backlight OFF, Alarm (LSP SD) ON

You see the "tricky" part as getting the display backlight to switch ON when the switch is at position 2 which you reduced to "lighting a LED at the middle position". However, it would be much easier to think of it like this: "How do I switch the display backlight OFF when the switch is in position 3?"

In principle, an NPN transistor as a low side switch for the display backlight with the base normally pulled high to keep the display backlight on. In position 3 the base is held low, switching the transistor (and backlight) off. You'll need the diodes already mentioned to avoid a direct connection between 1 and 3 on the switch, when connecting the alarm, and a couple of resistors.

I think you mean that the middle pin is grounded and each of the others goes to the negative of a component to turn it on.

No, The amplifier chip has a extra input to turn it off while grounded.
It's a PAM8302A with a 1uA shutdown current to the shutdown pin.
The TFT Display Backlight can be PWS-dimmed. Grounded is off then.


  • The DPDT is a idea.
  • I finally found a MCP23017 with some unused ports on the circuit for a software solution.
  • I can't add a free style soldered circuit with transistors etc. because it's a serial product. The LED is a enhancment.

Some ideas for a super simple circuit with a DPDT ? Something like:

Thx a lot to all the solution contributors!

PS: I solved it with the port expander chip in software.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.