Open doors with sequence ringing on intercom

Hello,

I want to make a secret door ring that would open the doors.

I have the intercom hooked up on arduino and i've set it that it reads voltages constantly. I also have relay connected to output pin.

I get 2,4-2,7V when ringer not pressed and 1,6-1,8V when ringer is pressed.

I made a simple code that if the voltages are between 1,6 and 1,8 it opens doors for 3seconds and it works.

Now i want to make a special ringing sequence that only that would open doors. So it would not open doors to everyone who rings.

I was thinking something like "111" "000" "111" "000" "1111111111" (this is indication of lenght of holding the ring button down)

I was thinking of going with an array. First set one array with 6 variables(3 for door rings and 3 for pauses).

Lets say that the first ring is 300millis long. There the first problem accurred. I can put 300millis into array but that would be impossible for a human to hold precise. How do i get it to be between 200 and 400 ms and still be a single value?

And the second problem is about recognising the rings.

I tried something like this:

double p1=0;
 double p2=0;
 double p3=0;
 double pa1=0;
 double pa2=0;
 double pa3=0;
   
 double correct[]={a,b,c,d,e,f,g};
 double seq[]={ugasnjen,p1,pa1,p2,pa2,p3,pa3};

if(push=1){
   timer=millis();
   seq[index]=millis();
   index++;

   if(index<6 || timer>5000) index=0;
 }
 else{
   seq[index]=millis();
   index++;
   if(index<6 || timer>5000) index=0;
   }

push is defined as 1 or 0 in if sentence measuring voltage.
Timer is set to 5 seconds, so it resets if u fail to get the correct.

If you want to ensure that some condition continues for a certain time you can use code like this

btnVal = digitalRead(btnPin);
if (btnVal == HIGH) {    // assumes btn is LOW when pressed
   lastBtnPressMillis = millis();   // btn not pressed so reset clock
}
if (millis() - lastBtnPressMillis > = interval) {
   // button has been pressed for longer than interval
}

Obviously you would adapt it to analogRead()

You might want to extend the example to check that the press was not too long - leave a good gap between the min and max times to allow for human frailty.

You could have the sequence of times in an array and when one length has been achieved you would load the next time values from the array.

If the button press is not of the correct duration you would set the whole process back to the start.

Frankly I suspect users would find the whole thing very inconvenient.

...R