I need a wiring diagram!

philipmfunder

Oct 4, 2025
2
Joined
Oct 4, 2025
Messages
2
I am a visual tech, and have this problem: I have one momentary switch, two lights, and four dpdt/four spdt relays if needed. I need to be able to push the momentary button and alternate between light 1 and light two. It can start with light 1 on. Push button, light 2. Push, light 1, etc.

I have read the theory many times, but am struggling. Can someone draw a simple diagram that shows how to wire this? No other components are an option.
 

AnalogKid

Jun 10, 2015
3,045
Joined
Jun 10, 2015
Messages
3,045
Your question is not at all clear. Are you saying you want to use the relays as logic elements to create a toggle flipflop?

ak
 

philipmfunder

Oct 4, 2025
2
Joined
Oct 4, 2025
Messages
2
Your question is not at all clear. Are you saying you want to use the relays as logic elements to create a toggle flipflop?

ak
I am not familiar with the term toggle flip flop. I did search that just now and it appears to be what I am looking for, though, yes.
 

danadak

Feb 19, 2021
1,063
Joined
Feb 19, 2021
Messages
1,063

There are quite a few videos on youtube on relay logic.....

Some possible help :


Option A — simplest, if you have a DPDT latching (bistable) relay or you can use a push-on/push-off (maintained) pushbutton


  • This is the cleanest: a maintained pushbutton toggles the relay state or a bistable (flip) DPDT relay changes contacts each push. Only one relay and one pushbutton required.

ASCII wiring diagram (12 V coil example — adapt voltages as needed):

+V -----(push-on/push-off)------+---- Coil + (of DPDT latching relay)
|
Coil
|
GND -----------------------------+---- Coil -

DPDT contacts (common = C, normally closed = NC, normally open = NO)

Pole A Pole B
C1 -----* *----- NO1 C2 -----* *----- NO2
\ / \ /
NC1 NC2

Wire the two poles to the lights so:
C1 -> +V (or supply hot)
NO1 -> Light1 -> GND
NO2 -> Light2 -> GND

When relay is in position A (one coil state) NO1 closes → Light1 on.
When relay toggled to position B (other state) NO1 opens and NO2 closes → Light2 on.


Step wiring:


  1. Use a DPDT latching relay whose two contact poles swap between Light1 and Light2 when the relay is toggled.
  2. Feed the lamp common from the relay poles as above.
  3. Use a push-on / push-off switch to energize the relay coil (or use the relay’s coil polarity reverse toggle if it’s a polarity-sensitive latching type).

Why this is easiest: the relay remembers the state mechanically — no electronics or extra relays needed.




Option B — if you only have momentary relays (non-latching) and one momentary pushbutton
Use a tiny CMOS flip-flop (CD4013 dual D-flip flop) or a small microcontroller to convert the momentary button presses into a toggling output that drives two DPDT relays (or two coils of one DPDT relay if you have a latching coil driver). This is slightly more parts but robust and common in hobby builds.


Block diagram + wiring summary:


  1. Pushbutton (momentary) -> debounce circuit -> clock input of a D flip-flop (CD4013).
  2. Configure the D-FF as a toggle: tie D = /Q (inverted Q) so each clock pulse toggles Q.
  3. Q drives Relay K1 coil (via driver transistor). /Q drives Relay K2 coil (via driver transistor).
  4. Use the relays’ DPDT contacts to feed Light1 when K1 is active, and Light2 when K2 is active. If you prefer only one relay physically, use a DPDT relay driven by one coil for Light1 and the other pole for Light2, but two small relays is simplest.

Schematic (logic + relay drivers in text):

PB ---||---(R,C debounce)---CLK of CD4013
Vcc -> CD4013

CD4013: connect D = !Q
So each CLK pulse toggles Q.

Q ----> transistor driver ----> Relay K1 coil -> GND
/Q ---> transistor driver ----> Relay K2 coil -> GND

Use relay contacts:
K1.NO -> Light1 -> GND
K2.NO -> Light2 -> GND
(Or wire commons to supply as appropriate)


Parts:


  • CD4013 (or CD74xx equivalent)
  • 2 small DPDT relays (coil voltage matching supply)
  • 2 NPN transistors (e.g. 2N2222) or small MOSFETs, base resistors, flyback diodes across each coil
  • debounce: RC or small Schmitt debounce (recommended)

Why this works: the flip-flop counts (toggles) on each push; Q = 1 -> Light1, Q = 0 -> Light2. Using DPDT relays keeps mains isolation for the lights.




Which to pick?​


  • If you have a latching (bistable) DPDT relay or can use a push-on/push-off switch, use Option A. It’s the simplest wiring and uses only the relay and the switch.
  • If you only have momentary relays and want the pushbutton to be momentary, use Option B (CD4013 + drivers). It’s cheap, reliable, and gives exactly the press-once/press-again behavior.



Quick wiring checklist (practical)​


  1. Decide coil voltage (12 V, 24 V, 5 V) and use relays and transistor drivers matching that.
  2. Add diodes across relay coils (flyback diodes) if driving from DC.
  3. Put a debounce (RC or small IC) on the pushbutton for reliable counting.
  4. If lights are mains voltage, only switch the mains with the relay contacts — keep coil and logic isolated and powered separately.


 

danadak

Feb 19, 2021
1,063
Joined
Feb 19, 2021
Messages
1,063
Power on considerations :

1) Option A — latching / bistable DPDT relay or a push-on/push-off switch

  • Behaviour at power-up: a mechanical latching relay or a maintained push-button already remembers its last mechanical state, so the lamps will come up in whatever contact state the relay is currently in (Light1 or Light2).
  • Pros: no electronics required for initialization.
  • Cons / safety note: if you want a specific state every time the box is powered, you must mechanically leave the relay in that state (or use a switch position). If the relay was left on Light2 and you want Light1 by default, the latching relay won’t change itself at power up.

If you want a guaranteed initial state with a latching relay, add a small manual switch that forces the relay to the desired state at power-up, or use an interlock that forces the relay to one position while power is applied.




2) Option B — momentary pushbutton + CD4013 (or microcontroller) driving relays


  • Behaviour at power-up: CMOS flip-flops like the CD4013 come up in an undefined state unless you explicitly reset/set them on power-up. That means Q or /Q could be either high or low and your lamps could be in either state. Because this is electronic, you must include a power-on initialization (POR) so the logic, relay drivers and relays go to a known safe state every time.

Robust, recommended ways to handle initialization​


Pick one of these three — any will work:


A. Power-on reset / supervisor IC (recommended, simple & reliable)


  • Use a small reset supervisor (watchdog/POR) such as MCP130 / MCP131 / MAX809 / MAX810 / TLV803 (choose one rated for your Vcc). These parts assert a reset output during power-up until Vcc is stable.
  • Wire the supervisor output to the RESET (and/or SET) input(s) of the CD4013 so the flip-flop is forced into a defined state (e.g., RESET asserted → Q = 0 so Light2 or Light1 as you prefer).
  • Advantages: tiny, inexpensive, reliable over wide temperature and supply edge rates.

B. Simple RC power-on reset with a transistor (cheap, but less precise)


  • Use an RC that creates a short pulse on the CD4013’s asynchronous SET or RESET so the flip-flop is forced to the desired state for a few tens/hundreds of ms while the supply stabilizes.
  • Example design approach (practical, not a recipe you must copy verbatim): use an RC time constant of about 0.1–1 s (e.g. R = 100 kΩ, C = 4.7–10 µF) combined with a small NPN to generate a clean reset pulse to the CD4013’s RESET pin. Add a diode to ensure the reset releases quickly on brown-in/out if needed.
  • Caveat: an RC POR is sensitive to very slow supply rises and can behave inconsistently; choose values and components carefully or prefer a dedicated supervisor.

C. Microcontroller option


  • If you use an MCU (e.g., small PIC/ATTINY/Arduino), use its built-in brown-out and startup code to explicitly set outputs (drive relays OFF or set Light1/Light2) before enabling relay drivers. The MCU toolbox makes deterministic initialization trivial.
  • Add a small delay or wait for BOD (brown-out detect) to be satisfied before releasing relays.

Additional safe/robust wiring practices (applies to any electronic solution)​


  • Keep relays OFF until logic stable: design drivers so the default state (no Vcc or undefined inputs) does not energize coils. Use pull-downs on transistor bases/gate to hold drivers OFF at power-up.
  • Use flyback diodes across coils and base/gate resistors to prevent spikes during transients.
  • Delay relay coil enable for a short time after POR expiry (a second or few hundred ms) to avoid chatter if the supply is noisy. A supervisor IC plus a simple RC delay on the enable pin works well.
  • If controlling mains lamps, design default state to the safest (usually both lamps OFF) until everything is initialized.



Concrete example (safe and simple): CD4013 + supervisor​


  • Vcc = 12 V (or use a 5 V regulator for the logic)
  • Supervisor: MCP130 (5 V version if you run logic at 5 V). Connect its /RESET (active low) to the CD4013 reset pins (pull them inactive after POR). Configure the supervisor so it holds reset active until Vcc > threshold.
  • CD4013: use one D-flip flop as toggle; tie D = /Q. Tie the flip-flop RESET to the supervisor so at power-up the flip-flop is forced to Q=0 (or tie SET if you want Q=1 at startup).
  • Relay drivers: transistors with base resistors and pull-downs so transistor is OFF while reset is asserted.
  • Result: on every power-up the circuit comes up in the same, safe lamp state.


 

danadak

Feb 19, 2021
1,063
Joined
Feb 19, 2021
Messages
1,063
A very simple approach is use block language on an Arduino Nano board.

And use it to drive the relays to switch the loads.

This has advantage that pushbutton is debounced.

Here is example I think would work :

1759584396999.png

This is mBlock program, free. You drag and drop the blocks into right hand window,
and configure their values, like which pin # or a variables value. mBlock then
generates Arduino code you use to program board using Arduino IDE (also free).
Board to use is Nano, ~$3.

You use the pins to drive relays thru a transistor. Something like this -

1759584630871.png

6'th graders using this to program simple robots.


Regards, Dana.
 

AnalogKid

Jun 10, 2015
3,045
Joined
Jun 10, 2015
Messages
3,045
I am not familiar with the term toggle flip flop. I did search that just now and it appears to be what I am looking for, though, yes.
A toggle flipflop starts up with one of the two outputs energized. This can be random, or the circuit can be modified so that it always starts in the same mode.

Power is applied to the circuit > Action B starts

Press button > Action B stops. Action A starts
Release button > Action A continues

Press button > Action A stops. Action B starts.
Release button > Action B continues.

Press button > Action B stops. Action A starts
etc.

ak
 
Top