Digital output uncontroled HIGH

This little sketch doesn’t work as I thougth. The state of digital outputs changes to HIGH at every 10 sec and sometimes it happens after 10 sec and then once again in less then 1 sec and then again after 10 sec and 10 and <1 and 10…
Digital outputs are connected to 2-port relay (connected to the wire remote of the Nikon DSLR. BTW - this connection works fine).
Where do these sporadic <1 sec delays come from?

*const int relayPin1 = 10; //focus and mettering signal *
const int relayPin2 = 11; //shutter signal
void setup() {

  • pinMode(relayPin1, OUTPUT); *
  • pinMode(relayPin2, OUTPUT);*

void loop()

  • digitalWrite(relayPin1, HIGH); //set focus and mettering*
  • delay(300);*
  • digitalWrite(relayPin2, HIGH); //fire the shutter*
  • delay (300);*
  • digitalWrite(relayPin1, LOW);*
  • digitalWrite(relayPin2, LOW);*
  • delay(10000);*

Where do these sporadic <1 sec delays come from?

What are you expecting it to do? You have delay(300) which is 300ms between the pins going HIGH and then LOW, then wait 10 seconds before going HIGH again.

Digital outputs are connected to 2-port relay

Is that relay capable of being driven by a 20mA digital pin?

Do you have protection (freewheel) diodes across the relay windings (if it really is an electromagnetic relay)?

We need to see your circuit…

This is the relay I use (geeetech 2-Channel DC 5V Relay Module for PIC ARM DSP AVR):

What I want is that the first chanel of the relay go on for 300ms alone then with the second one for another 300ms and then both chanels to off for 10 sec and then all over again.

It all works fine except for occasional <1sec “after shot”.