Upstairs / Downstairs Light Switching

Hi all,

I would like to control the overhead lights in a stairwell. Plain on & off is sufficient, no need for fading etc. I’d like to use standard on/off toggle home light switches (so not momentary push buttons). SWMBO doesn’t like buttons :slight_smile:

I know how to wire 2 traditional switches for this. For this application, I have 4 individual switches. I have the switches arranged so that in the “on” position, they give a 12VDC signal, off is 0V.

I would like to feed 5V of the 12V signal from each switch into a digital input pin of an Arduino Pro Mini, one switch to one pin. (I think I can drop the 12V to 5V with a simple resistor bridge, yes?)

When any of the 4 pins change state (from 5V to 0V or vice-versa), I would like one output pin to change state. I can then use this to control mains lighting in the stairwell via an optocoupler and a relay. Debouncing is no doubt necessary; the switched outputs have a resistor & capacitor, but I believe that some software debouncing would help too.

Could someone kindly point me to the code to do this please?

Many thanks,

Ian

Why such a complex solution? Why not use 2 x 3-way and 2 x 4-way switches which are the usual solution to this?

My question as well.

The answer to your question is not an Arduino, but a single 74HC86 or 74HC280. :sunglasses:

And some resistors.

No code required, no de-bouncing. :grinning:

Thanks gents!

I have a mix of household switches and metalclad switches (some are in a workshop), so I didn't think any of the off the shelf solutions would be suitable; to be honest, I didn't even consider them.

The AND / NAND gates look like a great solution. I actually have a couple of AND gates in stock, but not this particular type - again, I hadn't considered their use.

I'm struggling to see how the 74HC86 works (it's the device between my ears that's the problem, not the IC!) , but the 74HC280 is clearer to me; if the state of any one switches changes, the number in any one state changes from odd to even, or vice versa, and the output state changes. That would do it. And as you say, no programming.

I'll try the 74HC280.

Many thanks,

Ian

The 74HC280 can be emulated by a few 74HC86s. A parity generator is nothing more than a number of cascaded EX-OR (AKA XOR) gates. To use the 74HC86, you would simply feed your four inputs into two of the gates, then feed the two outputs of those into a third. You have a gate left over; you could use it to add a fifth input. Any left-over inputs must be tied to something, doesn't matter much whether Vcc or ground.

There is a stupid blunder in the logic diagram of the 74HC280 datasheet by the way. :grinning: Can you spot it?

Figure 2 on page 2? The same error repeated 9 times?

Indeed. :grinning:

I have some difficulty understanding the mixture of 12, mains and now 5 volts in that circuit and what you have to preserve from the existing circuit.
Why is 12 volts used for signalling in this proposed installation if you are talking about 5 volt signalling ?

With normal domestic lighting if there is a power glitch, the lights return to their original state. That is, if these were previously on, they are on after the power is restored. Do you require that function ?

6v6gt:
With normal domestic lighting if there is a power glitch, the lights return to their original state. That is, if these were previously on, they are on after the power is restored. Do you require that function ?

With the straightforward digital logic - the EX-OR gates - that will indeed be achieved de-facto. :grinning:

Paul__B:
With the straightforward digital logic - the EX-OR gates - that will indeed be achieved de-facto. :grinning:

Even after a power cycle ? I suppose with a big capacitor near the chip and a diode to prevent anything else on the +5V draining it, and further assuming the chip was supplying only a tiny current (not, for example, supplying an opto-coupler led directly) it could survive a power glitch.

It is pure combinatorial, not sequential logic. If the inputs - in this case mechanical switches - remain the same and I do not see how a power glitch will move a mechanical switch, then the output will be the same. :roll_eyes:

Paul__B:
It is pure combinatorial, not sequential logic. If the inputs - in this case mechanical switches - remain the same and I do not see how a power glitch will move a mechanical switch, then the output will be the same. :roll_eyes:

Ah yes. The state is defined purely by the state of the inputs which, being toggle switches, naturally survives a power glitch. Much more reliable that having the state defined by a cell in RAM as would be required if using momentary push buttons, or similar.