220V Light dimmer with Arduino – Lamp brightness control

It is very easy to build a good and simple AC light dimmer using Arduino, this light dimmer is used to control the brightness of a simple 220V AC lamp. In this project I used the LM393 integrated circuit (dual comparator IC) for zero crossing detection of the AC voltage and BT136 triac which supplies the load (lamp) depending on the firing angle (alpha).

Related Projects:
The following two project may contain some useful information.
SCR control with Arduino – Half-wave controlled rectifier
Controlled bridge rectifier with Arduino

Components Required:
This is a list of the basic components needed to build this project.

  • Arduino board
  • BT136 Triac  —  datasheet
  • 220V AC lamp
  • LM393 (or LM339) comparator
  • Optocoupler (MOC3020, MOC3021, MOC3022, MOC3023)  —  datasheet
  • 2 x 1N4007 diode (or 1N4001)
  • 2 x 220k ohm resistor
  • 10k ohm potentiometer
  • 10k ohm resistor
  • 470 ohm resistor
  • 120 ohm resistor
  • 100 ohm resistor
  • 0.01µF capacitor
  • Breadboard
  • Jumper wires

Arduino lamp brightness control

Arduino light dimmer circuit:
Project circuit schematic diagram is shown below.

Arduino light dimmer circuit

All grounded terminals are connected together.

In this project I used the LM393 (dual comparator IC) for the zero crossing detection, the LM339 quad comparator IC also can be used. An optocoupler can be used for the same purpose( zero crossing detection) but I think the comparator is much better. The two diodes which are connected between the non-inverting input (+) and the inverting input (-) of the comparator are used to limit the voltage across the 2 pins. The output of the LM393 (or LM339) is an open collector, so I added a 10k ohm resistor there (between +5V and arduino pin 2). Also the comparator chip is supplied with +5V which comes from the Arduino board.

The optocoupler (MOC302x) is used for firing the BT136 triac, its LED is connected to Arduino pin 8 through 120 ohm resistor. I chose the value 120 ohm in order to get a current of about 30mA (current passes through the optocoupler LED).

The 10k potentiometer is used to control the firing angle and therefore the brightness of the lamp.

Arduino light dimmer code:
The frequency of my AC source is 50Hz which means the period is 20ms, so the half wave period is 10ms = 10000µs.
The resolution of Arduino ADC module is 10-bit which means the digital value can vary between 0 and 1023.

I used Arduino interrupt (INT0 on pin 2) to detect the zero-crossing events, so when there is a zero crossing event (falling or rising), the Arduino interrupted and after some delay (angle alpha) it fires the triac.

Arduino light dimmer video:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.