Table of Contents
“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
- Zero crossing detector circuit explanation
- Light dimming circuit explanation
- Arduino programming and finally 4
Other Tools and Components:
Please Note: these are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!
Zero Crossing Detector Circuit:
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.
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:
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…
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 the video Tutorial given at the end.
int zeroc = 2 ;
int triac = 3 ;
int vresistor = A0; // variable resistor
int vrpower = 7;
attachInterrupt(0, angle, RISING);
brightness = analogRead(vresistor);
brightness = map(brightness,0,1023,0,10000);