# Toggle state between two circuits with two momentary switches

I have two circuits each with their own 1.5v power supply. I would like to toggle state between the two circuits with a switch, so that hitting a momentary switch turns the light off on one and turns the light on on the other. I've been able to wire in the momentary switch on each circuit but I need them to toggle each other.

I've looked into flip-flops but I'm a bit lost and haven't been able to figure out the best way to connect the two independent circuits. No code, this needs to be done with discrete components.

Sorry if this is a stupid question, I'm still learning the basics. Thanks for any tips/pointers.

• pls throw a rough diagram of the blackbox circutry. what are the voltage levels? – User323693 Jul 8 '15 at 2:59
• Umar, I added a diagram. – John Smith Jul 8 '15 at 13:48
• So, you need to short circuit 1's Q6 and Q7 while making Q6 and Q7 of circuit 2 open. And vice versa. What is the frequency of toggling? What is the supply available to you?can it be done using mechanical switch? – User323693 Jul 8 '15 at 14:40
• 1.5v for each circuit as indicated in the original post as well as the diagram. Frequency of toggling is random. Mechanical switch, yes of course. – John Smith Jul 8 '15 at 15:12
• Can you guarantee the states of the LEDs on power-up? – EM Fields Jul 8 '15 at 15:33

What you need to build is called a Bistable Multivibrator. Basically with a pulse as applied, the circuit will toggle from one state to the other.

With multivibrator circuits, you can have two output - one being the inversion of the other. With such an arrangement, you could then use something like an optocoupler to connect each output to one of the "black box" circuits.

Interestingly, this is exactly what a flip-flop is. If you get a D-type flip-flop with Q and !Q outputs, all you need to do is wire the D input to the !Q output, and connect your push button to the clock input. Finally you connect the Q an d !Q outputs to the two optocouplers which are then connected to your boards.

To improve things, you'll also need some debouncing on the push button to avoid multiple clock pulses. This can be done using an R-C circuit and a Schmitt trigger to generate a nice clock pulse from the push button.

I can draw up a circuit if that is easier to follow.

• Thanks Tom. Do I need to use an optocoupler or is there an alternative to connecting the output from the multivibrator to the boards? Can I wire straight into it and use a diode for protection? – John Smith Jul 8 '15 at 13:21
• @JohnSmith It depends on the circuit it is being connected to - if the circuit has different voltage requirements from the voltage you run the flip-flop circuit at it could cause damage. The idea behind the optocoupler is it eliminates the need for a common ground between the devices which may or may not be an issue - there isn't enough information to tell. – Tom Carpenter Jul 8 '15 at 13:52
• Both boards are powered by 1.5v AAA. I attached a simplified diagram to the original post if that helps. – John Smith Jul 8 '15 at 13:57
• That isn't enough information to make a call. Without knowing what the electrical specifications of the connector are, it is impossible to say for certain what can be connected. I would suggest playing it safe an using an optocoupler - they aren't exactly expensive and are quite easy to come by. – Tom Carpenter Jul 8 '15 at 15:35
• Thank you Tom. I'll heed your advice. I tried to upvote your answer but I don't have high enough reputation. Go figure. – John Smith Jul 8 '15 at 16:24

If it works on each circuit independently you could always use a NOT gate to switch the logic for the 2nd circuit. This may not be useful information, maybe I could clarify if you provided a simple schematic?

• Thanks Josh. Unfortunately the circuit is a bit of a black box. It's an "off the shelf" circuit with a custom ASIC, but I have two test pads on each that when connected toggles the state of the LED. – John Smith Jul 8 '15 at 2:38
• Josh, I attached a simplified diagram. – John Smith Jul 8 '15 at 14:40

I am being naive I think. Hope you have heard of DPDT switch. Dual pole dual throw switch. You can use it and close the issue. Terminal A,B,C,D of DPDT can be wired in this way. A goes to Ckt1 Q6, B is open. C is open. D goes to Ckt2 Q6. P and Q terminals are connected to Ckt1 Q7 and Ckt2 Q7. When the DPDT is in one state, circuit one will be closed, and when the DPDT is in another state the circuit 2 will be closed.

A----o

o---------- P

B----o

C----o

o---------- Q

D----o


P and Q both operate together.both can move up or down together. When P contacts A, Q contacts C. When P contacts B , Q contacts D. These switches are easily available for purchase.

• Yes, I have heard of DPDT switches but in this instance I need two switches. Physically they will be about 1m apart. – John Smith Jul 8 '15 at 16:25
• Why di you need two switches? DPDT switch wont mind a meter length of cable for the purpose of toggling the LED. Half a meter on either side – User323693 Jul 8 '15 at 16:28
• Two switches is what he asked for. "Toggle",in this case, means that when he presses either switch the state of both LEDs will change, then, when he releases the switch, the LED states won't change. When he presses either switch again, though, the LEDs will toggle, and so on... The problem with the DPDT switches, I believe, is that there's never a time when half of the switch isn't made, so the other switch will never be able to affect the LED which corresponds to that set of made contacts. But perhaps I'm missing something and you could post a schematic to set me straight? – EM Fields Jul 10 '15 at 22:59

There seems to be an inherent problem with the circuit in that if both LEDs come up OFF on power up, then subsequent simultaneous toggling will keep them locked in phase unless the symmetry is somehow broken.

On power-up in the schematic below, U1-RST is held momentarily low by the integrator R3C2, which forces U1-OUT low while the power supply output comes up to voltage. Also, U1's TRIG input is held high by the network R1R2C1D1, further insuring that U1-OUT will stay quiescently low.

C5R5 is a differentiator, and is used to drive one of the inputs and the output of U2 high for a short time after power-up, that pulse being used to ensure that the LED associated with ASIC 1 (not shown) will be ON after power-up, while the LED associated with ASIC2 will not.

Thereafter, whenever S1 or S2 is made, a short,low-going edge will be presented to U1-TRIG, which will start the timer and cause its output to send a high-going pulse to K2 and to k1 through U2. that pulse will cause K1 and K2's contacts to close momentarily, which will cause the ASIC LEDs to toggle, with ASIC1's LED turning off and ASIC2's LED turning on.

Later, if either S1 or s2 are made another pulse will be generated which will toggle the LEDs back to their starting state, and the cycle will begin anew.

K1 and K2 are shown as relays, but could just as easily be analog switches if their ON resistances were low enough for the ASICs to accept as valid "contact closures".

In the meantime, if you'd like to play around with the cicuit, here's the .asc file:

Version 4
SHEET 1 1584 900
WIRE -368 96 -592 96
WIRE 48 96 -368 96
WIRE 528 96 48 96
WIRE 752 96 528 96
WIRE 1072 96 752 96
WIRE 1184 96 1072 96
WIRE 752 176 752 96
WIRE 1072 176 1072 96
WIRE -368 192 -368 96
WIRE -208 192 -368 192
WIRE -112 192 -208 192
WIRE 272 192 96 192
WIRE 464 192 336 192
WIRE 528 192 528 96
WIRE 528 192 464 192
WIRE -368 224 -368 192
WIRE -208 224 -208 192
WIRE -112 240 -112 192
WIRE 528 256 528 192
WIRE 96 288 96 192
WIRE 192 288 96 288
WIRE 464 288 464 192
WIRE 464 288 416 288
WIRE 752 320 752 240
WIRE 848 320 752 320
WIRE 896 320 848 320
WIRE 1072 336 1072 256
WIRE -368 352 -368 304
WIRE -320 352 -368 352
WIRE -208 352 -208 304
WIRE -208 352 -256 352
WIRE -112 352 -112 304
WIRE -112 352 -208 352
WIRE 192 352 -112 352
WIRE 464 352 416 352
WIRE 896 352 800 352
WIRE 1024 352 960 352
WIRE 1024 400 976 400
WIRE -368 416 -368 352
WIRE -112 416 -368 416
WIRE 192 416 144 416
WIRE 464 416 464 352
WIRE 464 416 416 416
WIRE 528 416 528 336
WIRE 528 416 464 416
WIRE 1072 448 1072 416
WIRE -368 464 -368 416
WIRE -112 464 -112 416
WIRE -416 480 -496 480
WIRE -160 480 -240 480
WIRE 48 480 48 96
WIRE 192 480 48 480
WIRE 1184 480 1184 96
WIRE 144 544 144 416
WIRE 800 544 800 352
WIRE 800 544 144 544
WIRE 1024 544 800 544
WIRE 1184 592 1184 560
WIRE 1184 592 1072 592
WIRE -592 608 -592 96
WIRE -496 608 -496 480
WIRE -240 608 -240 480
WIRE 752 608 752 320
WIRE 1072 608 1072 592
WIRE 528 624 528 416
WIRE 1024 624 1024 544
WIRE -592 736 -592 688
WIRE -496 736 -496 688
WIRE -496 736 -592 736
WIRE -416 736 -416 528
WIRE -416 736 -496 736
WIRE -368 736 -368 544
WIRE -368 736 -416 736
WIRE -240 736 -240 688
WIRE -240 736 -368 736
WIRE -160 736 -160 528
WIRE -160 736 -240 736
WIRE -112 736 -112 544
WIRE -112 736 -160 736
WIRE 96 736 96 288
WIRE 96 736 -112 736
WIRE 528 736 528 688
WIRE 528 736 96 736
WIRE 752 736 752 688
WIRE 752 736 528 736
WIRE 976 736 976 400
WIRE 976 736 752 736
WIRE 1024 736 1024 672
WIRE 1024 736 976 736
WIRE 1072 736 1072 688
WIRE 1072 736 1024 736
WIRE -592 816 -592 736
FLAG -592 816 0
FLAG 1072 448 0
FLAG 848 320 SET
SYMBOL sw -368 560 M180
SYMATTR InstName S1
SYMBOL res -224 208 R0
WINDOW 0 -44 40 Left 2
WINDOW 3 -62 73 Left 2
SYMATTR InstName R2
SYMATTR Value 100k
SYMBOL cap -256 336 R90
WINDOW 0 0 32 VBottom 2
WINDOW 3 32 32 VTop 2
SYMATTR InstName C1
SYMATTR Value 100n
SYMBOL res -384 208 R0
WINDOW 0 -32 33 Left 2
WINDOW 3 -36 67 Left 2
SYMATTR InstName R1
SYMATTR Value 10k
SYMBOL voltage -240 592 R0
WINDOW 3 24 96 Invisible 2
WINDOW 123 0 0 Left 2
WINDOW 39 0 0 Left 2
SYMATTR Value PULSE(0 5 5.5 1ms 1ms 1 3)
SYMATTR InstName V3
SYMBOL voltage -592 592 R0
WINDOW 3 29 93 Left 2
WINDOW 123 0 0 Left 2
WINDOW 39 0 0 Left 2
SYMATTR Value 5
SYMATTR InstName V1
SYMBOL diode -96 304 R180
WINDOW 0 24 64 Left 2
WINDOW 3 24 0 Left 2
SYMATTR InstName D1
SYMATTR Value 1N4148
SYMBOL sw 1072 704 M180
SYMATTR InstName S4
SYMBOL res 736 592 R0
SYMATTR InstName R4
SYMATTR Value 1meg
SYMBOL cap 736 176 R0
SYMATTR InstName C4
SYMATTR Value 470n
SYMBOL sw 1072 432 M180
SYMATTR InstName S3
SYMBOL Digital\\or 928 400 M180
WINDOW 3 -8 -20 Invisible 2
SYMATTR Value trise 50n tfall 50n vhigh 5v
SYMATTR InstName U2
SYMBOL res 1056 160 R0
SYMATTR InstName R5
SYMATTR Value 10k
SYMBOL res 1168 464 R0
SYMATTR InstName R6
SYMATTR Value 10k
SYMBOL Misc\\NE555 304 384 R0
SYMATTR InstName U1
SYMBOL cap 336 176 R90
WINDOW 0 0 32 VBottom 2
WINDOW 3 32 32 VTop 2
SYMATTR InstName C2
SYMATTR Value 100n
SYMBOL res 512 240 R0
SYMATTR InstName R3
SYMATTR Value 1meg
SYMBOL cap 512 624 R0
SYMATTR InstName C3
SYMATTR Value 100n
SYMBOL sw -112 560 M180
SYMATTR InstName S2
SYMBOL voltage -496 592 R0
WINDOW 3 24 96 Invisible 2
WINDOW 123 0 0 Left 2
WINDOW 39 0 0 Left 2
SYMATTR Value PULSE(0 5 1 1ms 1ms 1 3)
SYMATTR InstName V2
TEXT -576 784 Left 2 !.tran 20 startup
TEXT -576 760 Left 2 !.model SW SW(Ron=.01 Roff=1G Vt=2.5  Vh=0)

• You're absolutely right about LEDs both being off, I hadn't even thought of that. Thanks for the sample circuit to solve the problem, I'll study it and play around with it. – John Smith Jul 9 '15 at 15:07