Electronic – How to make a digitally controlled power switch


I am new to electronics. I want to make a power switch controller by a digital pin as shown on the following figure.

How to do this safely?

enter image description here

Update: I forgot to let you know the bulb is just an example for the sake of drawing. The real scenario, it is a female socket into which any equipment male socket is inserted.

Best Answer

Updated after update of the question. Changes are regarding the zero-crossing

The best solution for an incandescent lamp is an SSR (Solid State Relay) with zero-crossing detection. (Zero-crossing switching increases the bulb's life.) An SSR module is the most convenient, but they're not cheap.

enter image description here

If you want to switch other (unknown) loads you better pick a random-switching SSR, i.e. without the zero-crossing circuit.

If price is an issue you can better build the SSR from discrete components. Below is an example using the MOC3041 as opto-triac. Will cost about 2 euros.

enter image description here

Again, the MOC3041 has a zero-crossing circuit. For other loads than an incandescent bulb use the random switching MOC3051.

Not as nice, but easier: an electromechanical relay:

enter image description here

The transistor is needed because the microcontroller can't supply the required current for the relay, so you have to amplify this current.

About the zero-crossing: you may have noticed that incandescent bulbs always fail when they're switched on. That's because the mains phase can be near its maximum when switching on. Combined with the low resistance of a cold bulb this results in a high current peak, which may burn the filament. When you switch on a zero crossing you avoid these peaks.

Related Topic