Electronics‎ > ‎

AC Light Dimmer

posted Jan 9, 2012, 2:37 AM by Andrew Jessop   [ updated Jan 9, 2012, 2:41 AM ]

March 2006

This project came about because a friend of mine had something similar as a component for his final year electronic engineering project. We decided that we would have a kind of competition to see who could build an AVR based AC light dimmer the quickest. I was interested because I had always wanted to experiment with AC power control, and this was the perfect, simple little project.

AC Dimming Theory

Explanation to go here.


The schematic for the dimmer is of a fairly simple design. The zero crossing detector is based on a diode bridge which rectifies the AC into full wave. This will go to zero each half cycle. The transistor is then used to switch the optocoupler on as the voltage rises above ~0.7v. The triac is the main switching device for the load since this is an AC dimmer. The control is fully isolated from the AC source so this circuit could be used to switch higher voltages as long as proper precautions are taken.


The code for this project was written in BASCOM AVR - a BASIC compiler for the AVR microcontrollers. The code is fairly simple and is only two pages long.  The main loop just polls the port where the zero crossing detector is connected. If there is a zero crossing, then wait for a short time to give the voltage on the base of the transistor time to fall to zero instead of 0.7v, and start the timer.  The timer interrupt just coverts a brightness based on a 50Hz (or is it 100Hz due to rectification?) time period and turns the triac on. The triac will automatically turn off at the next zero crossing, so the timer is reset to maintain the brightness.


Silicon Chip

Andrew Jessop,
Jan 9, 2012, 2:37 AM
Andrew Jessop,
Jan 9, 2012, 2:37 AM