Using a millis command to sync the different movement of two Servos

First off, I am very new to programing and Arduino and the code I am trying to modify was originally writing by Dave Gundlach from Thingiverse (original code Box).

The problem: I have built a useless box that uses two servos but, they are not moving in a coordinated way. dServo opens the door and fServo turns the switch off. My sync issue is with the dServo closing before the fServo has completely retracted.

My goal: I am trying to use a function that can tell when the fServo has been giving the command to close, pause for about 1000 milliseconds without a delay() function and then close the door.

I have been going through this site and the forums without any luck. There are examples but I can’t seem to figure out how to get them into the code I am using.

Any help would be appreciated.

//  by Dave Gundlach Feb 2015
*/
// LIBRARIES //
#include <Servo.h> 
#include <ADCTouch.h>
#include <avr/sleep.h>
#include <avr/power.h>

// DEFINED CONSTANTS //
#define SWITCH_PIN 2
#define CAP_SEN_PIN A0
#define FSERVO_PIN 9
#define DSERVO_PIN 10
// GLOBAL VARIABLES
int fServo_Max = 10;         // Maximum Finger Servo Value (retracted)
int fServo_Min = 120;          // Minimum Finger Servo Value (extended)
int dServo_Max = 5;         // Maximum Door Servo Value (retracted)
int dServo_Half = 30;         // Half Open Door Servo Value
int dServo_Min = 55;          // Minimum Door Servo Value (extended)
int fingerVal = fServo_Max;   // Value of Finger Servo
int ref0, ref1;               // reference values to remove offset
int capProx = 3;              // sensitivity for proximity
int capTouch = 100;           // Sensitivity for switch touch
int prox = 0;                 // Proximity state
int touch = 0;                // Touch state
int switch_state;             // Switch state
unsigned long act_timer;      // Activity Timer
int act_count = 1;            // Activity Counter
int tantFlag = 0;             // Tantrum Flag
unsigned long startMillis;
unsigned long currentMillis;
const unsigned long period = 1000;
// DEFINE SERVOS //
Servo fServo;                 // Finger Servo
Servo dServo;                 // Door Servo

void setup() 
{ 
  Serial.begin(9600);                // Serial for Debug
  fServo.attach(FSERVO_PIN);          // Assign Pin to Finger Servo
  dServo.attach(DSERVO_PIN);          // Assign Pin to Door Servo
  fServo.write(fServo_Max);           // Finger Servo to Retracted Postition
  dServo.write(dServo_Max);           // Door Servo to Retracted Position
  pinMode(SWITCH_PIN, INPUT_PULLUP);  
  ref0 = ADCTouch.read(A0, 500);      // create reference values to... 
  ref1 = ADCTouch.read(A1, 500);      // account for the capacitance of the pad
  act_timer = millis();               // Set Acvity Timer
  cCalibrate();                       // Run capacitance calibration function
} 

 // SWITCH OFF - Turn switch off//
void sw_off(){
  int i = 0;                          // reset counter
  while(!digitalRead(SWITCH_PIN)){    // while switch on
    dServo.write(dServo_Min);         // Open Door
    fingerVal = fServo_Min - i;       // Set finger position 
    i = i-1;
    if (fingerVal <= fServo_Max){     // check if finger reached limit
      i = i+1;                          // don't move finger past limit
    }
    fServo.write(fingerVal);          // Move finger to new position
  }
    fServo.write(fServo_Min);        // retract finger
    dServo.write(dServo_Min);            // close door
}

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

have you checked into this one ?

I have been through that one numerous times and I am sure that the answer is there. I just can’t seem to make it work in my program.

This is what I added to my program.

/// GLOBAL VARIABLES
unsigned long startMillis;
unsigned long currentMillis;
const unsigned long period = 1000;


void setup() 
{ 
    startMillis = millis();
}


void loop()

void sw_off(){
  int i = 0;                          // reset counter
  while(!digitalRead(SWITCH_PIN)){    // while switch on
    dServo.write(dServo_Min);         // Open Door
    fingerVal = fServo_Min - i;       // Set finger position 
    i = i-1;
    if (fingerVal <= fServo_Max){     // check if finger reached limit
      i = i+1;                          // don't move finger past limit
    }
    fServo.write(fingerVal);          // Move finger to new position
  }
    fServo.write(fServo_Min);        // retract finger
    currentMillis = millis();
    if (currentMillis - startMillis >= period)
    {
      dServo.write(dServo_Min);            // close door
      startMillis = currentMillis;
    }
    
}

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.