Servo rotate to 0 degrees after timeperiod

Hi

I’ve coded a program so that when you send a letter to the Arduino, it either unlocks or locks the door. What I would like to add to this is that when the doorlock servo has been in unlocked position for 10min or so, it would rotate back to locked. How could I achieve that?

You can find the existing code down below

Thanks in advance

#include <SoftwareSerial.h>
#include <Servo.h>
SoftwareSerial mySerial(0,1);
Servo servo;
#define  pos_ini 0
void setup()
{
mySerial.begin(9600);
Serial.begin(9600);
servo.write(pos_ini);
servo.attach(7, 500, 2500);
}
void loop()
{
int i;
 
if (mySerial.available())
{
i=mySerial.read();
if(i=='u')
{
 Serial.println("Unlocked");
 servo.write(90);
}
if(i=='l')
{
 Serial.println("Locked");
 servo.write(0);
}
}
}

Save the value of millis() when the door becomes unlocked. Then in loop(), if the door is currently unlocked, check whether 10 minutes has elapsed since the saved time and lock it and flag it as locked

Thanks for the reply. I found out that if I disconnect from the module manually or walk out of its range the servo will reset to its “locked” position. So that solves that