My scheme has MOC3043 with zero-crossing detection.
I use two pins to control the dimmer: detectorPin to analyse input voltage wave and controlPin to drive optocoupler. The program is very simple thanks to zero-crossing MOC.
I attached an
interrupt to the input detectorPin on
CHANGE event. And controlPin is used as digital output. When I test detection with controlPin unplugged everything works fine. But when controlPin is connected, value which is read inside the interrupt becomes wrong! So my dimmer cannot detect any half-wave and reports errors. This happens at the moment when controlPin value is set to
HIGH with help of
digitalWrite() func. After nearly 40-50 milliseconds detected values go back to normal, so most of time my dimmer work as expected.
I measured current on the controlPin, it's only 3.2mA, which is lower than maximum possible current for Arduino Due.
I tested this with detectorPin = 51, and different controlPins: 52, 36, 31.
So, how do you think, what is the problem? Is my Arduino broken?