AC dimming using zero crossing

@Leroy: Did you use interrupts OR polling? Why 5W resistors (for 230V only 1mW is emitted)?

The 5W resistors are there for a bit more safety so that in case of short-circuit or high impulse voltages, the stuff wouldn't blow off the PCB.

The code we use is without interrupts, just reading the inputs:

A snippet:

void loop()
{
  Serial.println('duration');
  pulseHigh = pulseIn(optoH, HIGH);
  pulseLow = pulseIn(optoL,LOW);
  duration= pulseHigh+pulseLow;
  duration = duration / 1E6;
  fre=(1/duration);
  int potValue = analogRead(A0);

We use a 16MHz arduino Uno which is fast enough to pick its nose between the sinewave zero-crossings.

I will try the code without interrupts and also measure output from the optocoupler and the signal from the Triac. Sadly I need to wait until I am home (~3h). I report back with the results.

Using the zero crossing signal to delay the triac gating
is correct, but, that signal is at twice the line frequency.
Is that causing a problem of pulsing the gate at the
wrong time?

Edit: Oh, now I see that allows the triac to conduct
on both half cycles!