AC Fan Speed Control Using Arduino and TRIAC (/microcontroller-Projects/ac-Fan-Speed-Control-Using - Arduino-And-Triac)
AC Fan Speed Control Using Arduino and TRIAC (/microcontroller-Projects/ac-Fan-Speed-Control-Using - Arduino-And-Triac)
ARDUINO (HTTPS://CIRCUITDIGEST.COM/ARDUINO-PROJECTS)
arduino-and-triac) (https://bit.ly/34JX0QT )
The CR01005 chip resistor
By (page_author.html)Debasis Parida (/users/debasis-parida) Feb 05, 2020 8 features a three-layer termination
(https://bit.ly/34JX0QT
process with a nickel barrier
)
SRP0310 /
SRP0315/SRP0410 /
SRP0510 / SRP0610 Series
Shielded Power Inductors
(https://bit.ly/31ZvmxA )
(https://bit.ly/31ZvmxA
SRP0310/0315/0410/0510/0610
) shielded power inductors have a
metal alloy powder core and flat wire
1. Arduino UNO
2. 4N25 (Zero crossing detector)
3. 10k Potentiometer
4. MOC3021 0pto-coupler
5. (0-9)V, 500 mA Stepdown Transformer
6. BT136 TRIAC
7. 230 VAC Axial AC fan
8. Connecting wires
9. Resistors
(https://bit.ly/2QkLGCH)
Working of AC fan control using Arduino
The working can be divided into four different parts. They are as follows
Automotive
Microcontrollers from
STMicroelectronics to
(/news/automotive-
2. Phase Angle controlling Circuit Maximize Safety and
microcontrollers-Security in Next-Generation
stmicroelectronics-
Domain/Zone Architectures
After detecting the point of zero crossing, now we have to control the amount of timing
maximize- (/news/automotive-
for which the power will be ON and OFF. This PWM signal safety-and- microcontrollers-
security-for- stmicroelectronics-
(https://circuitdigest.com/tags/pwm) will decide the amount of voltage output to the AC
next- maximize-safety-and-
motor, which in turn controls the speed of it. Here a BT136 TRIAC is used, which controls security-for-next-
generation-
the AC voltage as it is a power electronic switch for controlling an AC voltage signal. generation-domain-zone-
domain-zone-
architectures)
architectures)
TRIAC (https://circuitdigest.com/tutorial/triac-switching-circuit-and-applications) is a
three-terminal AC switch that can be triggered by a low energy signal at its gate terminal.
In SCRs, it conducts in only one direction, but in the case of TRIAC, the power can be
controlled in both directions. To learn more about TRIAC
(https://circuitdigest.com/tutorial/triac-switching-circuit-and-applications) and SCR
(https://circuitdigest.com/tutorial/what-is-thyristor-how-it-works), follow our previous
articles.
As shown in the figure above, the TRIAC is triggered at a firing angle of 90 degrees by
applying a small gate pulse signal to it. The time “t1” is the delay time which is given as
per the dimming requirement. For example, in this case, the firing angle is 90 percent,
hence the power output will also be halved and hence the lamp will also glow with half
intensity.
We know that the frequency of the AC signal is 50 Hz here. So the time period will be 1/f,
which is 20ms. For a half cycle, this will be 10ms or 10,000 microseconds. Hence for
controlling the power of an AC lamp, the range of “t1” can be varied from 0-10000
microseconds.
Optocoupler:
Optocoupler (https://circuitdigest.com/tutorial/opto-coupler-types-working-applications)
is also known as Optoisolator. It is used to maintain isolation between two electrical
circuits like DC and AC signals. Basically, it consists of an LED that emits infrared light
and the photosensor which detects it. Here a MOC3021 optocoupler is used to control the
AC Fan from the microcontroller signals which is a DC signal.
Here a potentiometer is used to vary the speed of AC Fan. We know that a potentiometer
is a 3 terminal device that acts as a voltage divider and provides a variable voltage output.
This variable analog output voltage is given at the Arduino analog input terminal to set the
speed value of the AC fan.
Circuit Diagram
Circuit diagram for this Arduino based 230v fan speed control circuit is given below:
(/fullimage?I=circuitdiagram_mic/Arduino-Fan-Control-using-TRIAC-Circuit-Diagram.jpg)
SPONSORED SEARCHES
Schematic Diagram
Electronic Circuit
Note: I have shown the complete circuit on a breadboard only for the purpose of
understanding. You should not use 220V AC supply directly on your breadboard, I have
used a dotted board to make the connections as you can see in the image below
After the hardware connection, we need to write up the code for Arduino, which will
generate a PWM signal (https://circuitdigest.com/tutorial/what-is-pwm-pulse-width-
modulation) to control the AC signal ON/OFF timing using a potentiometer input. We
previously used PWM techniques in many projects (https://circuitdigest.com/tags/pwm).
The complete code of this Arduino AC fan speed control project is given at the bottom of
this project. The stepwise explanation of the code is given below.
In the first step, declare all the required variables, which are going to be used throughout
the code. Here the BT136 TRIAC is connected to pin 6 of Arduino. And the variable
speed_val is declared to store the value of speed step.
int TRIAC = 6;
int speed_val =0;
Next, inside setup function, declare the TRIAC pin as output as PWM output will be
generated through this pin. Then, configure an interrupt
(https://circuitdigest.com/tags/interrupts) to detect the zero-crossing. Here we have used
a function called attachInterrupt, which will configure digital Pin 3 of Arduino as external
interrupt and will call the function named zero_crossing when it detects any interrupts at
its pin.
void setup()
{
pinMode(LAMP, OUTPUT);
attachInterrupt(digitalPinToInterrupt(3), zero_crossing, CHANGE);
}
Inside the infinite loop, read the analog value from potentiometer which is connected at
A0 and map it to a value range of (10-49).
To find out this range we have to do a small calculation. Earlier it is told that each half
cycle is equivalent to 10,000 microseconds. So here the dimming will be controlled in 50
steps which is an arbitrary value and can be changed. Here the minimum steps are taken
as 10, not Zero because 0-9 steps give approximately the same power output and
maximum steps are taken as 49 as it is not recommended practically to take the upper
limit (which is 50 in this case).
Then each step time can be calculated as 10000/50= 200 microseconds. This will be
used in the next part of the code.
void loop()
{
int pot=analogRead(A0);
int data1 = map(pot, 0, 1023,10,49);
speed_val=data1;
}
In the final step, configure the interrupt-driven function zero_crossing. Here the dimming
time can be calculated by multiplying the individual step time with no. of steps. Then after
this delay time, the TRIAC can be triggered using a small high pulse of 10 microseconds
which is sufficient to turn on a TRIAC.
void zero_crossing()
{
int chop_time = (200*speed_val);
delayMicroseconds(chop_time);
digitalWrite(TRIAC, HIGH);
delayMicroseconds(10);
digitalWrite(TRIAC, LOW);
}
Complete code along with a working video for this AC fan control using Arduino and
PWM is given below.
Code
int TRIAC = 6;
int speed_val=0;
void setup()
pinMode(TRIAC, OUTPUT);
void zero_crossing()
delayMicroseconds(chop_time);
digitalWrite(TRIAC, HIGH);
delayMicroseconds(10);
digitalWrite(TRIAC, LOW);
void loop()
int pot=analogRead(A0);
speed_val=data1;
}
Video
INTERRUPTS (/TAGS/INTERRUPTS)
Email Address *
Name
Country
United States of America
Subscribe
RELATED CONTENT
(/microcontroller-projects/simple- (/microcontroller-projects/interfacing-
arduino-rc-boat-that-can-be-controlled- gravity-inrared-co2-sensor-to-measure-
wirelessly-using-rf-module) carbon-dioxide-in-ppm)
Build a Simple Arduino RC Boat that can Interfacing Gravity Infrared CO2 Sensor
be Controlled Wirelessly using 433 MHz with Arduino to Measure Carbon Dioxide
RF Modules (/microcontroller- in PPM (/microcontroller-
projects/simple-arduino-rc-boat-that-can- projects/interfacing-gravity-inrared-co2-
be-controlled-wirelessly-using-rf-module) sensor-to-measure-carbon-dioxide-in-
ppm)
(/microcontroller-projects/arduino-based- (/microcontroller-projects/air-quality-
automatic-surface-disinfecting-robot- analyzer-using-arduino-and-nova-air-
using-ultraviolet-lights) quality-sensor-sds011)
Automatic Surface Disinfecting Robot Air Quality Analyzer using Arduino and
using Ultraviolet Lights (/microcontroller- Nova PM Sensor SDS011 to Measure
projects/arduino-based-automatic- PM2.5 and PM10 (/microcontroller-
surface-disinfecting-robot-using- projects/air-quality-analyzer-using-
ultraviolet-lights) arduino-and-nova-air-quality-sensor-
sds011)
(/microcontroller-projects/arduino-touch- (/microcontroller-projects/li-fi-
sensitive-color-changing-plants-using-rgb- communication-between-two-arduino)
leds) Li-Fi based Text Communication between
Touch Sensitive Color Changing Plants Two Arduino (/microcontroller-projects/li-
using Arduino and RGB LEDs fi-communication-between-two-arduino)
(/microcontroller-projects/arduino-touch-
sensitive-color-changing-plants-using-rgb-
leds)
(/microcontroller-projects/cell-phone-
controlled-fingerprint-solenoid-door-lock-
using-arduino)
Cell Phone Controlled Fingerprint
Solenoid Door Lock using Arduino and
HC-05 (/microcontroller-projects/cell-
phone-controlled-fingerprint-solenoid-
(/microcontroller-projects/interfacing-
door-lock-using-arduino)
sharp-gp2y1014au0f-sensor-with-arduino-
to-build-air-quality-analyzer)
Interfacing Sharp GP2Y1014AU0F Sensor
with Arduino to build Air Quality Analyser
(/microcontroller-projects/interfacing-
sharp-gp2y1014au0f-sensor-with-arduino-
to-build-air-quality-analyzer)
COMMENTS
Graham (/users/graham)
Feb 07, 2020
(/users/graham)
This is a DANGEROUS and bad design.
Log in (/user/login?destination=node/4818%23comment-form) or register
(/user/register?destination=node/4818%23comment-form) to post comments
Do not attempt to build this circuit, unless you have mains circuit
experience.
3. Series resistor between the MC3021 and TRIAC are usually 100 ohm,
not 1K as shown.
Can I ask to have this posting and circuit removed from Circuit Digest?
tfmoe (/users/tfmoe)
Mar 10, 2020
(/users/tfmoe)
Hi @Graham,
Log in (/user/login?destination=node/4818%23comment-form) or register
(/user/register?destination=node/4818%23comment-form) to post comments
Jay (/users/jay-4)
Jun 06, 2020
(/users/jay-4)
Thanks for the detailed insights Graham. This helps
Log in (/user/login?destination=node/4818%23comment-form) or register
(/user/register?destination=node/4818%23comment-form) to post comments
newbies to be aware before trying out such things.
leconghau (/users/leconghau)
Oct 02, 2020
(/users/leconghau)
the circuit you made has run already ???
Log in (/user/login?destination=node/4818%23comment-form) or register
(/user/register?destination=node/4818%23comment-form) to post comments
leconghau (/users/leconghau)
Oct 02, 2020
(/users/leconghau)
where i am living does not sell opto 4N25 ... only sell
Log in (/user/login?destination=node/4818%23comment-form) or register
(/user/register?destination=node/4818%23comment-form) to post comments
4N35, i have used that alternative .. but the circuit is not yet running
Wish
(https://circuitdigest.com/power-
Subscribe
(https://www.facebook.com/circuitdigest/)
(https://twitter.com/CircuitDigest)
(https://www.youtube.com/channel/UCy3CUAIYgZdAOG9k3IPdLmw)
(https://www.instagram.com/circuit_digest/)
(https://www.pinterest.com/circuitdigest/)
electronics) ARDUINO PROJECTS
(/ARDUINO-PROJECTS)
Analog Electronics
(https://www.linkedin.com/company/circuit- RASPBERRY PI PROJECTS
(https://circuitdigest.com/analog-
(/SIMPLE-RASPBERRY-PI-
electronics) PROJECTS-FOR-BEGINNERS)
digest/)
Internet of Things
ELECTRONICS NEWS
(https://circuitdigest.com/internet-
(HTTPS://CIRCUITDIGEST.COM/NEWS)
of-things)
ELECTRONICS FORUM
Audio Electronics (HTTPS://CIRCUITDIGEST.COM/FORUMS)
(https://circuitdigest.com/audio-
electronics) CALCULATORS
(HTTPS://CIRCUITDIGEST.COM/CALCULATORS)
Electric Vehicles
(https://circuitdigest.com/electric-
vehicles)
Events
(https://circuitdigest.com/events)
Copyright © 2020 Circuit Digest (http://circuitdigest.com/). All rights reserved. Privacy Policy (http://circuitdigest.com/privacy-policy) | Cookie Policy
(https://circuitdigest.com/cookie-policy) | Terms of Use
(https://circuitdigest.com/terms-of-use) | Contact Us
(http://circuitdigest.com/contact) | Advertise (http://circuitdigest.com/advertise)