AC Light Dimmer Module with fade effect



This post shows how to fade your 220V/110V LED light using AC Light Dimmer Module with Arduino.

 

AC Light Dimmer Module

AC Light Dimmer Module 1 Channel 3.3V/5V Logic AC 50hz 60hz 220V 110V

Buy at lowest price from Amazon




This module works on PWM ( Pulse Width Modulation Control ) in simple words we decrease or increase the duty cycle to set the intensity of the LED.

PWM is also used to

  • Control dimming of RGB strip.
  • Control the direction of the servo motor
  • Control the speed of the motor

The main advantage of PWM light dimmer is that it very energy efficient.

light Fader

You can buy it from here.


Parts Needed

You need to have the following parts

  • Arduino (Any version)
  • 1x AC Light Dimmer Module 1 Channel
  • 1x 220V/110V LED
  • Jumper Wire

Arduino Setup

Wiring Light Dimmer Module

Wiring Relay

Pin Wiring Dimmer to the Arduino
VCC 5V or 3.3V
GND GND
Z-C PIN – 2
PWM PIN – 3

 

 

Schematics For Arduino

Assemble all the parts by following the schematics below:


AC light dimmer schematic

Connect the LED lamp to the AC Load and dimmer to the AC input.


Coding Arduino

/*
Pin    |  Interrrupt # | Arduino Platform
---------------------------------------
2      |  0            |  All -But it is INT1 on the Leonardo
3      |  1            |  All -But it is INT0 on the Leonardo
18     |  5            |  Arduino Mega Only
19     |  4            |  Arduino Mega Only
20     |  3            |  Arduino Mega Only
21     |  2            |  Arduino Mega Only
0      |  0            |  Leonardo
1      |  3            |  Leonardo
7      |  4            |  Leonardo
The Arduino Due has no standard interrupt pins as an iterrupt can be attached to almosty any pin. 

In the program pin 2 is chosen
*/
int AC_LOAD = 3;    // Output to Opto Triac pin
int dimming = 1024;  // Dimming level (0-128)  0 = ON, 128 = OFF

void setup()
{
  Serial.begin(115200);
  pinMode(AC_LOAD, OUTPUT);// Set AC Load pin as output
  attachInterrupt(0, zero_crosss_int, RISING);  // Choose the zero cross interrupt # from the table above
}

//the interrupt function must take no parameters and return nothing
void zero_crosss_int()  //function to be fired at the zero crossing to dim the light
{
  // Firing angle calculation : 1 full 50Hz wave =1/50=20ms 
  // Every zerocrossing thus: (50Hz)-> 10ms (1/2 Cycle) 
  // For 60Hz => 8.33ms (10.000/120)
  // 10ms=10000us
  // (10000us - 10us) / 128 = 75 (Approx) For 60Hz =>65

  int dimtime = (65*dimming);    // For 60Hz =>65    
  delayMicroseconds(dimtime);    // Wait till firing the TRIAC    
  digitalWrite(AC_LOAD, HIGH);   // Fire the TRIAC
  delayMicroseconds(8.33);         // triac On propogation delay 
         // (for 60Hz use 8.33) Some Triacs need a longer period
  digitalWrite(AC_LOAD, LOW);    // No longer trigger the TRIAC (the next zero crossing will swith it off) TRIAC
}

void loop()  {
for (int i=880; i <= 902; i++){
  if (i==902){
    dimming=0;
    delay(100);
    }
  else{
    dimming=i;
    Serial.println(i);
    delay(5);
  }
   }

for (int i=902; i >= 880; i--){
    if (i==902){
    dimming=0;
    delay(100);
    }
    else{
    dimming=i;
    Serial.println(i);
    delay(5);
    }
   }
   
}

Note: There is a different setting for 50Hz and 60Hz supply. Change the values in the code accordingly.

  • Adjust the Dimming Range accordingly ( For us 880 to 902 worked).
  • Upload the code to the Arduino.