Auto-lock for my car. Timing issue.

Hi I'm new to this forum and would like to ask for some advice.

I am making an auto-lock for my car and I have made my code.

The lock will send a pulse every 34 seconds if the conditions are met for example if the door is closed.

If the remote is pressed to open the door then reset the counter which will then allow you enough time before getting in the car to avoid the circuit tries to close the door.

int remote = 0;
int door = 1;
int lock = 2;
//int core_Open = 3;
//int Rescue_Button = 4;

void setup()

 {
    // Setting up things once when Auduino is first turned on.
   
    // Setup pins
    pinMode(remote, INPUT);
    pinMode(door,   INPUT);
    pinMode(lock,   OUTPUT);
    //cli(); // disable global interrupts
    //sei(); // enable interrupts

 }

void loop()

{
       
     // If door is closed, then lock
     if(digitalRead(door) == LOW)
    {
      digitalWrite(lock, HIGH);
      delay(500);
      digitalWrite(lock, LOW);
    }
    
    
    else
    {
      digitalWrite(lock, LOW);
    }
    
    delay(34000);

  
 // If remote is detected high then delay
 
         if(digitalRead(remote) == HIGH)
       {
           delay(34000);
       }
       
}

The problem is is that the 34 seconds isn't exact. It's always random between 34 seconds-1minute 20.
What can I do which will give me the exact time of my choosing?

Well you delay 34 seconds. Then, if remote is HIGH, you delay another 34 seconds. That's 1 minute 8 seconds.

It may be a good idea to put "UL" after the 34000. That means the compiler will treat the number as an unsigned long rather than an int, since 34000 is too big for an int.

The remote isn't high and it's still going to 1 minute something. Thought integer can go up to 35000. My mistake.

Will try this. Thanks

Thanks for the feedback.

Get rid of "delay", 34 second on micro-controller scale is a millenium. Look into Examples/Digital/ Blink w/o Delay.