Relay Driver with Flyback Diode: Circuit, Measurements and Online Simulator
To build this Relay Driver with Flyback Diode circuit you need a bench power supply, a 12 V battery, a toggle switch, a 4.7 kΩ resistor, a 2N2222 NPN transistor, a relay (5 V coil, SPDT), a 1N4148 diode and a 12 V 1 W bulb. A 5 V relay coil, switched by a transistor, turns a 12 V bulb on and off through its contacts — two circuits, electrically isolated. You hear it click. Make the 12 connections in the wiring table, press Run, and and flip the switch: the armature pulls in 5 ms later (you hear it), the NO contact closes and the bulb lights. The diode across the coil protects the transistor from the coil kick when it lets go.
Open this circuit in the free Electronics bench simulator
Parts list
| Qty | Part | What it does |
|---|---|---|
| 1 | Bench Power Supply | Set the voltage and a current limit. It holds the voltage (CV) until the load wants more than the limit, then holds the current (CC). + and − float; GND is earth. |
| 1 | 12 V battery | A DC source with a little internal resistance. + is the longer terminal. |
| 1 | Toggle Switch | An on/off switch between its two terminals. Flip it while the circuit runs. |
| 1 | 4.7 kΩ resistor | Limits current. 220 Ω in series with an LED; 10 kΩ as a pull-up or pull-down. |
| 1 | 2N2222 NPN transistor | A small base current (B→E) lets a current β times larger flow C→E. Use a base resistor (1 kΩ from a pin) to switch loads. |
| 1 | Relay (5 V Coil, SPDT) | A real relay: the 70 Ω coil pulls in above ~50 mA and releases below ~20 mA, 5 ms later each way (you hear the click). COM connects to NC at rest and to NO when energised. Drive the coil through a transistor, with a flyback diode. |
| 1 | 1N4148 diode | Conducts from A (anode) to K (cathode, the striped end) once about 0.7 V is across it; blocks the other way. |
| 1 | 12 V 1 W bulb | A filament bulb. Cold, its resistance is a tenth of its hot value, so it draws a surge at switch-on and glows up over a few tens of ms. |
Wiring
| # | From | To |
|---|---|---|
| 1 | Bench Power Supply + | Toggle Switch 1 |
| 2 | Toggle Switch 2 | 4.7 kΩ resistor leg 1 |
| 3 | 4.7 kΩ resistor leg 2 | 2N2222 NPN transistor B |
| 4 | 2N2222 NPN transistor E | Bench Power Supply - |
| 5 | Bench Power Supply - | Bench Power Supply GND |
| 6 | Bench Power Supply + | Relay (5 V Coil, SPDT) COIL1 |
| 7 | Relay (5 V Coil, SPDT) COIL2 | 2N2222 NPN transistor C |
| 8 | 1N4148 diode K | Relay (5 V Coil, SPDT) COIL1 |
| 9 | 1N4148 diode A | Relay (5 V Coil, SPDT) COIL2 |
| 10 | 12 V battery + | Relay (5 V Coil, SPDT) COM |
| 11 | Relay (5 V Coil, SPDT) NO | 12 V 1 W bulb 1 |
| 12 | 12 V 1 W bulb 2 | 12 V battery - |
Step by step
- Open the electronics bench. Open the BitForBytes Embedded Lab in your browser. A circuit with no microcontroller runs on the analog bench: no install or account is needed.
- Add the parts. Add a bench power supply, a 12 V battery, a toggle switch, a 4.7 kΩ resistor, a 2N2222 NPN transistor, a relay (5 V coil, SPDT), a 1N4148 diode and a 12 V 1 W bulb from the parts palette (Instruments, Power, Passive and Semiconductors).
- Wire 1. Connect Bench Power Supply + to Toggle Switch 1.
- Wire 2. Connect Toggle Switch 2 to 4.7 kΩ resistor leg 1.
- Wire 3. Connect 4.7 kΩ resistor leg 2 to 2N2222 NPN transistor B.
- Wire 4. Connect 2N2222 NPN transistor E to Bench Power Supply -.
- Wire 5. Connect Bench Power Supply - to Bench Power Supply GND.
- Wire 6. Connect Bench Power Supply + to Relay (5 V Coil, SPDT) COIL1.
- Wire 7. Connect Relay (5 V Coil, SPDT) COIL2 to 2N2222 NPN transistor C.
- Wire 8. Connect 1N4148 diode K to Relay (5 V Coil, SPDT) COIL1.
- Wire 9. Connect 1N4148 diode A to Relay (5 V Coil, SPDT) COIL2.
- Wire 10. Connect 12 V battery + to Relay (5 V Coil, SPDT) COM.
- Wire 11. Connect Relay (5 V Coil, SPDT) NO to 12 V 1 W bulb 1.
- Wire 12. Connect 12 V 1 W bulb 2 to 12 V battery -.
- Run and measure. Press Run and flip the switch: the armature pulls in 5 ms later (you hear it), the NO contact closes and the bulb lights. The diode across the coil protects the transistor from the coil kick when it lets go.
Lab sheet
// Electronics bench: relay driver
//
// Control side: 5 V, switch, 4.7 kΩ into the NPN base; the coil from 5 V to the collector,
// a 1N4148 across the coil (cathode to +5 V) as a flyback diode.
// Load side: 12 V to COM, NO to the bulb, the bulb to 0 V. The sides share only a magnetic field.
//
// Coil: 70 Ω draws 71 mA at 5 V, above the 50 mA pickup. It lets go below 20 mA.
What to try
Press Run and flip the switch: the armature pulls in 5 ms later (you hear it), the NO contact closes and the bulb lights. The diode across the coil protects the transistor from the coil kick when it lets go.
Frequently asked questions
How do I wire the Relay Driver with Flyback Diode circuit?
Make 12 connections: Bench Power Supply + to Toggle Switch 1; Toggle Switch 2 to 4.7 kΩ resistor leg 1; 4.7 kΩ resistor leg 2 to 2N2222 NPN transistor B; 2N2222 NPN transistor E to Bench Power Supply -; Bench Power Supply - to Bench Power Supply GND; Bench Power Supply + to Relay (5 V Coil, SPDT) COIL1; Relay (5 V Coil, SPDT) COIL2 to 2N2222 NPN transistor C; 1N4148 diode K to Relay (5 V Coil, SPDT) COIL1; 1N4148 diode A to Relay (5 V Coil, SPDT) COIL2; 12 V battery + to Relay (5 V Coil, SPDT) COM; Relay (5 V Coil, SPDT) NO to 12 V 1 W bulb 1; 12 V 1 W bulb 2 to 12 V battery -.
What parts do I need for the Relay Driver with Flyback Diode?
A bench power supply, a 12 V battery, a toggle switch, a 4.7 kΩ resistor, a 2N2222 NPN transistor, a relay (5 V coil, SPDT), a 1N4148 diode and a 12 V 1 W bulb.
Can I simulate the Relay Driver with Flyback Diode online for free?
Yes. The BitForBytes Embedded Lab solves the circuit in time, the way SPICE does (nodal analysis with real diode, transistor and capacitor models), and gives you a bench power supply, function generator, oscilloscope and multimeter to measure it — free, in the browser.
What does this circuit show?
A 5 V relay coil, switched by a transistor, turns a 12 V bulb on and off through its contacts — two circuits, electrically isolated. You hear it click.
More Electronics bench projects
- RC Circuit Time Constant: Circuit, Measurements and Online Simulator
- Half-Wave Rectifier with Smoothing Capacitor: Circuit, Measurements and Online Simulator
- 555 Timer Astable LED Flasher: Circuit, Measurements and Online Simulator
- NPN Transistor Switch: Circuit, Measurements and Online Simulator
- Op-Amp Inverting Amplifier: Circuit, Measurements and Online Simulator
- Zener Diode Voltage Regulator: Circuit, Measurements and Online Simulator