MOC3021 light dimmer, Triac BTA16, Zero Crossing detector & Arduino

(Last Updated On: June 29, 2019)

MOC3021 light dimmer

Description:

“MOC3021 light dimmer” In this Tutorial, you will learn how to make an Arduino based 110/220vac Bulb dimming Control system using MOC3021, BTA16 Triac and a zero crossing detector circuit based on the EL817 optocoupler. The brightness can be controlled using the potentiometer. The Zero crossing detector circuit is designed in such a way that it provides complete isolation between the ac side and the controller side. So if any fault or short circuit happens on the ac side will have no effect on the controller side. In this Tutorial, we will cover

  1. Zero crossing detector circuit explanation
  2. Light dimming circuit explanation
  3. Arduino programming and finally 4
  4. Testing



The components and tools used in this project can be purchased from Amazon, the components Purchase links are given below:

Arduino Uno: https://amzn.to/2tVz1vu
Mega 2560: https://amzn.to/2ze1kdu
MOC3021 optoisolator Triac Driver: https://amzn.to/2Wo4VfV
BTA16 Triac: https://amzn.to/2JAeQ0f
EL817 optocoupler: https://amzn.to/2Tt6ZRF
Bridge Rectifier: https://amzn.to/2CB7kvY
lm7805 Voltage Regulator: https://amzn.to/2IZEl5x
330-ohm resistors pack: https://amzn.to/2NtlAeh
5v 2A adaptor: https://amzn.to/2GsNfcw
2n2222 npn transistors: https://amzn.to/2EmXsIb
10k Resistor: https://amzn.to/2KTd6OW
lm7805 Voltage Regulator: https://amzn.to/2IZEl5x
330-ohm resistors pack: https://amzn.to/2NtlAeh
female DC power jack socket: https://amzn.to/2KEo1gt
470 uf capacitors: https://amzn.to/2xDCOzf
5×7 cm vero board: https://amzn.to/2OHGbvn
female headers: https://amzn.to/2zqmtiJ
connection wires: https://amzn.to/2DpBuW7
Super Starter kit for Beginners: https://amzn.to/2KJvmKG
Jumper Wires: https://amzn.to/2KMoVXs
Bread Board: https://amzn.to/2MS4q8X
12v Adaptor: https://amzn.to/2Ntr6h1
PCB plate: https://amzn.to/2IUwpCt
Variable Supply: https://amzn.to/2MT4Qfj
Digital Multimeter: https://amzn.to/2Nvft9i
Vero Board / strip board: https://amzn.to/2MTf9jD
Soldering iron kit: “best” You guys should definitely purchase this: https://amzn.to/2zfoNuJ
Solder wire: https://amzn.to/2ufUMWf
Wire Stripper: https://amzn.to/2KOqxfU
wire cutter: https://amzn.to/2ucIq14
PCB small portable drill machine: https://amzn.to/2Nu62XF

Zero Crossing Detector Circuit:

MOC3021 light dimmer

This schematic is designed in cadsoft eagle 9.1.0 version. if you want to learn how to make a schematic and PCB then watch my tutorial given below.

The zero crossing detector circuit is very simple, let’s start with the 12v step-down transformer. You can use a 220/110  to 12v transformer. The secondary side of the transformer is connected with the ac input legs of the Bridge rectifier…this is the bridge rectifier as you can see it has 4 legs, two legs are labeled with the ac signs and two legs are labeled with the plus and minus signs.



The purpose of the bridge rectifier is to convert the ac into dc. Three 10k resistors are connected in series which makes the voltage divider circuit. With the help of these resistors, the voltage is reduced to 4volts. A 330-ohm resistor is connected in series with the IR led of the el817 Optocoupler….this is the el817 Optocoupler as you can see it has a total of four legs.

Leg number1 is the anode and leg number2 is the cathode. Leg number3 is the emitter while leg number 4 is the collector… This is a current limiting resistor. while the cathode of the ir led is connected with the ground of the bridge rectifier. On the right side of the el817, a 10k resistor is connected with the collector while the other side of the 10k resistor is connected with the Arduino’s 5v.

while the emitter of the el817 is connected with the Arduino’s ground.  Pin number 4 which is the collector is also connected with the Arduino’s pin number 2. As you can see clearly the Arduino side has no physical connection with the transformer side. So if anything happens on this side will have no effect on the other side. Now let’s have a look at the dimming circuit….

Dimming Circuit based on the MOC3021:

MOC3021 light dimmer

The ac bulb dimming circuit is based on the MOC3021opto-isolator Triac Driver and BTA16 triac. The moc3021 has actually total of 6 pins but pin number 3 and pin number 5 are not used.



Pin number 1 is the anode and pin number 2 is the cathode as per the datasheet…A 330 resistor is connected in series with the anode of the IR led. This is a current limiting resistor and will be connected with the Arduino. this pin will be defined in the programming..pin number 4 and pin number 6 are the main terminals as per the datasheet… 330-ohm resistors are connected with pin number 4 and pin number 6 of the moc3021…

MOC3021 light dimmer

this is the BTA16 triac lets have a look at its datasheet..as you can see it has three legs

First leg is the main terminal 1

2nd leg is the main terminal 2 while

3rd leg is the Gate.

The BTA16 triac can handle load upto 16A at 25C. for higher load large heat sink should be used…

The other side of the R2 resistor is connected with the main terminal1 of the triac and is also connected with the ac load, while the other side of the ac load is connected with the neutral…

The other side of the R3 resistor is connected with the main terminal2 and is also connected with the 220vac….

Pin number 4 of the moc3021 is also directly connected with the gate of the BTA16 triac…



A variable resistor is connected with the analog pin A0 of the Arduino. this variable resistor will be used to control the light intensity of the ac bulb. While the other two legs of the variable resistor are connected with the Arduino’s 5v and ground.

MOC3021 light dimmer Programming:

For the step by step program explanation, watch video Tutorial given at the end.

MOC3021 light dimmer Watch full Video Tutorial:

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply