Relay Connecting at the Start

I have written a program to control a relay but the problem is whenever I power on the Arduino, the relay synchronously connects for a very short time then it disconnects. I want the relay only connects when the condition is satisfied, yet not every time I power the Arduino.
My code:

void setup()  
{
  
//part of the code here not related to relay

  pinMode(10,OUTPUT);
}

void loop()                     
{
digitalWrite(10,HIGH);

//an if statement exists here that executes the following lines if it is satisfied

  digitalWrite(10,LOW);
  delay(1200);
  digitalWrite(10,HIGH);
}

Hi,

you set the output 'low' to activate the relay?

When you first power up the Arduino the output is low, relay activates, then you set the output to 'high' to release the relay?

Can you reverse the output so the relay is off when 'low' and activated when 'high'?

Peter

if LOW activates your relay, put a digitalWrite(10,HIGH); right after the pinmode.

Also, is pin 10 shared with other function on your board? It's part of the SPI interface for many boards.

set the output pin state before you configure it as an output.
not sure of HIGH/LOW deactivates the relay

void setup()
{
    //part of the code here not related to relay
    digitalWrite(10,HIGH);
    pinMode(10,OUTPUT);
}