Problem Adruino with 4ch relays

Hi, i have a problem. For my project (WPF) i'm using relays on pins 9, 10, 11, 12
but when i plug the arduino in to the USB it turns on the relays like this:

ON, 1sec.
OFF 5 sec.
and then it stays ON.

What i would like to have is : when i plug it in to the USB it stays OFF untill my program says it to turn ON

(Everything is fine and working, once the WPF program is started)

Can someone please help me??
Thanks.

this is the code i have used:

void setup()
{
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
Serial.begin(9600);

}

void loop()
{

if (Serial.available() > 0)
{
char c = Serial.read();

if (c == 'A')
{
digitalWrite(12, HIGH);
}
else if (c == 'B')
{
digitalWrite(12, LOW);
}

if (c == 'C')
{
digitalWrite(11, HIGH);
}
else if (c == 'D')
{
digitalWrite(11, LOW);
}

if (c == 'E')
{
digitalWrite(10, HIGH);
}
else if (c == 'F')
{
digitalWrite(10, LOW);
}

if (c == 'G')
{
digitalWrite(9, HIGH);
}
else if (c == 'H')
{
digitalWrite(9, LOW);
}

}
}

Try adding
digitalWrite (9, LOW);
digitalWrite (10, LOW);
digitalWrite (11, LOW);

digitalWrite (12, LOW);

in setup.

Thanks for the quick reply...

Just tried that, unfortunately it does not help

Bert1985:
Thanks for the quick reply...

Just tried that, unfortunately it does not help

You need to do it like this in setup:

digitalWrite (9, LOW);
digitalWrite (10, LOW);
digitalWrite (11, LOW);
digitalWrite (12, LOW);

pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);

You need to put it before you select the pins as output.

It all depends on the 4-channel relay module (which you didn't link to), and how you have connected it.

If it has opto couplers, you should write a HIGH to the pin (in setup) before you set the pin as output.
Then a HIGH in your code turns the relay off, and a LOW turns the relay on.

But you might have a relay module without opto couplers.
Then the previous answers could be right.
Leo..