Electronic – arduino – How to fade in and out light bulb(220V) (Arduino)

arduinorelay

I have relay conected with arduino and high voltage bulb, now how can I control voltage to fade in and out bulb? I know that a relay is an on off device so maybe a triac or IGBT would be needed?Would an optpcoupler be good for isolation? Should I use a PWM output on the arduino?

Best Answer

With a relay? You can't.

The relay contacts are either open (lamp fully off) or closed (lamp fully on) and can't switch a relay fast enough to give a dimming effect.

schematic

simulate this circuit – Schematic created using CircuitLab

What you're looking for is a triac controlled dimmer.

schematic

simulate this circuit

In this case an opto-coupled triac is used. Your micro would switch the LED D1 on at the appropriate point in the mains half-cycle turning on the triac. The triac stays on until the next zero-cross of the mains and then turns off. At 100 (50 Hz) or 120 (60 Hz) half-waves per second the flicker is not noticeable.

Your code would have to monitor the mains zero-cross somehow, ramp the delay in triggering the triac and pulse the optoisolator at the right time. Plenty of examples on a web search.