1
\$\begingroup\$

I want to make a circuit with an illuminated LED push-button that is far away from the input board and I only have 2 wires available. The push-button is not something specific. The input board will have many buttons, but not all buttons will have LEDs. The input board will probably be a MCP23017 16-bit expander with an MCU.

I came up with this circuit:

schematic

simulate this circuit – Schematic created using CircuitLab

The MCP23017 is powered with 5V.

When the push-button is not pressed, the voltage at the MCP input pin is about 1V, low enough to register a 0 on the digital input.

When the push-button is pressed, the voltage is 5.6V without the added 5.1V zener diode D3, and 5 volts with the zener in place - well above 0.8 * 5V VDD required by MCP23017. But because the circuit is just a voltage divider 220+220 ohm resistors over the 12V supply, it will draw ~28mA, resulting in a bit of heat from the resistors. Because the push-buttons will not be pressed for more than a few seconds, I can live with this.

D2 LED was actually an opto-coupler to separate the long wire from the digital input, but I gave up on this protection for now.

I searched a lot on the internet for other ideas about how to power an LED and have a button using only 2 wires and no complex circuitry, but could not find any relevant info.

I built this circuit and it works, but one thing I cannot test is the influence of mains wires that run alongside my long button wires. They are separated and individually protected, but parallel to each other.

Do you have any other suggestions on how to use a button and an LED on 2 wires?

Later edit:

The buttons can only be normally open. They are European type light push buttons available only NO. LED is added by me. Led should be lit all the time when the push-button is open. When the button closes there is no problem if the led tuns off or remains on. In this particular case, the led is used for night time finding only.

One other idea I had recently was to use input-output feature of the IO expander chip. Using the output to turn on the led, and then switch to input to check for the push-button state. Doing this fast enough not to see a flicker. But I haven't drawn any circuit yet.

\$\endgroup\$
5
  • \$\begingroup\$ Are the buttons normally-open (NO) only. It would be dead easy with NC contacts. Do you have a datasheet link for the button? LED should be normally lit? LED can go out when button pressed? (Put all the info into the question rather than in the comments.) \$\endgroup\$
    – Transistor
    Dec 4, 2019 at 16:58
  • \$\begingroup\$ Alex, I'm a little confused about something you wrote. You mentioned that these are "euro-type light push buttons" but you also mention that the "LED is added by me." If the euro-style PB types are already lighted, they probably have an LED or other kind of light already built into them. If you had to add an LED, you'd either have to modify the PB mechanicals or else install the LED separately to light up the button. If there is already a light in the PB, I'd prefer to see what they put inside... not what you want to add, now. But I'm confused. So perhaps you could clarify? \$\endgroup\$
    – jonk
    Dec 4, 2019 at 21:03
  • \$\begingroup\$ jonk, PB are single-throw single-pole mechanical switch designed for mains (230V AC) light control or doorbell for example, no ilumination by default. My added LED illumination does not modify the hardware button. \$\endgroup\$
    – AlexV
    Dec 5, 2019 at 18:42
  • \$\begingroup\$ What gauge are the wires? \$\endgroup\$
    – Maple
    Jun 5, 2020 at 15:58
  • \$\begingroup\$ 1.5mm squared or 16 AWG for americans \$\endgroup\$
    – AlexV
    Jun 25, 2020 at 11:45

3 Answers 3

0
\$\begingroup\$

If you still want isolation, you just need a source of low-voltage AC power:

schematic

simulate this circuit – Schematic created using CircuitLab

Each switch controls the LED at the other end of the long 2-wire cable.

Either LED could be part of an optoisolator.

D2 and D4 are only necessary if the peak voltage out of the transformer exceeds the LED reverse voltage rating.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks, I will test this idea because it is much simpler to implement in software and uses less pins. \$\endgroup\$
    – AlexV
    Dec 5, 2019 at 20:31
1
\$\begingroup\$

schematic

simulate this circuit – Schematic created using CircuitLab

Figure 1. A simpler circuit using two GPIO pins.

How it works:

  • IO2 toggles between high and low.
  • IO1 toggles between input and output high.

Table 1.

State  Button  IO1       IO2     LED
  1    Open    Out high  Out lo  ON
  2    Open    Input     Out hi  Off   IO1 reads low due to pull-down R2.
  3    Pressed Out high  Out lo  Off   LED shorted out.
  4    Pressed Input     Out hi  Off   IO1 pulled high by IO2.
  • Light the LED when IO1 is high and IO2 is low.
  • Read the switch when IO2 is high and IO1 is input.
\$\endgroup\$
1
  • \$\begingroup\$ Simple and elegant. The problem is 20m wires will pick up noise and add quite a lot of resistance of their own. Also some TWS would be advisable. \$\endgroup\$
    – Maple
    Jun 5, 2020 at 15:57
0
\$\begingroup\$

I'm planning to do the same thing as you. (Use EU Push buttons with LED backlight added by me and read them with Multiplexer PCF8574 -> MCU )

I've found this solution on hackaday: HariFun#133 More I/O Madness and I'm planning to use the same approach to solve the task.

It is implementation of your idea: Using the output to turn on the led, and then switch to input to check for the push-button state.

In the example code he's using bitbanging to read the inputs, but PCF8574 has also interrupt pin, so it's possible to go in that direction.

\$\endgroup\$
1
  • \$\begingroup\$ I suggest you elaborate on the solution. \$\endgroup\$ Jun 5, 2020 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.