Hello evryone, I am doing an end of study project and I have reached a point where I find myself with a problem whose cause I did not understand,I searched on google and I did not find clear answers on this subject.
I made a circuit of a zero crossing detector whose optocoupler is a 4n35 to control an optotriac "MOC3021" connected with a triac "BTA16" by the arduino, but when I visualize the detections I noticed that they are not periodically regularly as shown in the photo I think there are passages not detected.
the circuit is the same of this one just in the middle of the 55k resistors I put 47k and at the output of the rectifier bridge I put a 1.5k resistor.
C:\Users\Abdelghani\Desktop\picters
the code and the inputs from 4n35:
void setup() {
pinMode(2,INPUT);
Serial.begin(115200);
}
void loop() {
Serial.println(digitalRead(2));
Serial.print(" ");
}

I put the resistors without calculating just I looked at the circuits on google whose characteristics of the optocouplers are nearly the same of those of the 4n35, I think there is an error at the level of the resistors in addition I noticed that these heat up too much.
with this unorganized detection cycle, I tried a simple experiance with the code below where I sent an ammorassage angle of 1/4 of the full period "0.25 * 10 (ms) = 2.5 (ms) = 2500 (µs) "but finally the lamp illuminated 100% !!
void setup() {
attachInterrupt(digitalPinToInterrupt(2),aa_commande,FALLING);
pinMode(3,OUTPUT);
}
void loop() {
}
void aa_commande()
{
digitalWrite(3,HIGH);
delayMicroseconds(2500);
digitalWrite(3,LOW);
}
so i block here and i don't know where exactly the error is, so i'm waiting for yours answers, and thank you very much in advance.