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);*
    }

markohafner:
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):
http://www.ebay.co.uk/itm/2-Channel-DC-5V-Relay-Module-PIC-ARM-DSP-AVR-/280867102761?_trksid=p5197.m1992&_trkparms=aid%3D111000%26algo%3DREC.CURRENT%26ao%3D1%26asc%3D14%26meid%3D491828504722596008%26pid%3D100015%26prg%3D1006%26rk%3D1%26

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”.