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