# arduino + optotriac based ac dimmer blinking severely

I try to build a dimmer with arduino phase control and triac. I followed the schematic from

Now I used the software provided in the instructable link, but it is not working as it should. The light is simply blinking instead of dimming. So I used the following software to just glow the bulb without dimming:

unsigned int i=1;
void setup() {
Serial.begin(9600);
pinMode(AC_pin, OUTPUT);
pinMode(11, OUTPUT);
attachInterrupt(0, light, RISING);
}

void light(){
i++;
digitalWrite(11, LOW);
delayMicroseconds(10);
digitalWrite(11, HIGH);
}

void loop(){
if(i%100==0){
Serial.println("100");
i=1;
}
}


Following are the results: In the above code I am testing the zero crossing circuit just by counting upto 100, and printing a value (100) when it turns hundred. When i run the system without load (pin 11 is not connected to opto triac) it gives me almost perfect print rate of 1 per second (visibly) and steady. Now if i connect pin 11 to opto triac 3021, the output load bulb starts blinking (not steady at all), and also the output of optocoupler (4n25) gets randomized; Visibily i can see it is not giving output at every 1 second, rather it is somewhat random. Please note instead of MOC3021 i am using EL3021, and in place of TIC206 triac i used bt 136. I am not using any snubber right now. I also tried the software from http://wiki.dxarts.washington.edu/groups/general/wiki/4dd69/AC_Dimmer_Circuit.html. Still with no luck however their schematic is little bit different in terms of biasing but i am using exact values from the schematic attached. Please help me sorting out this problem.

• What happens if you change light() as follows: { digitalWrite(11, HIGH); delayMicroseconds(100); digitalWrite(11, LOW); } ? – jippie May 5 '13 at 20:14