Hello,
I brought this AC Light dimmer.
However, I can't get it to work. I use the example code that is given on their website (with some slight modifications) and connected my Arduino Uno to the Module.
I connected Zero-Crossing to Digital2 and PWM to Digital11. I also connected ACC and GND to 5V and GND on my Arduino.
I also connected a 220V LED Light bulb to the Load Connection and a Powerplug to AC-IN.
If I upload the code and plug in the Power, the light is always on without beeing dimmed.
There is small LED next to the PWM pin on the Module that is fading. So it seems like it should be working in principle.
Any Ideas Why it isn't working?
Simon
The code:
//ZERO----2
//DIMMER----11
int i;
int ZDpin=2;
void setup(){
Serial.begin(9600);
pinMode(2,INPUT);
pinMode(11,OUTPUT);
pinMode(13,OUTPUT);
pinMode(10,OUTPUT);
}
void light(){
delay(3);
digitalWrite(10,1);
}
void loop(){
i=digitalRead(10);
digitalWrite(13,0);
digitalWrite(10,0);
attachInterrupt(digitalPinToInterrupt(ZDpin),light,RISING);
delay(20);
if(i==1){
delay(3);
digitalWrite(13,1);
pwm();
}
}
void pwm()
{
for (int a=10; a<=255;a++)
{
analogWrite(11,a);
delay(8);
}
for (int a=255; a>=10;a--)
{
analogWrite(11,a);
delay(8);
}
//delay(800);
}