Restarting an if statement after it has been satisfied

Hello,
I'm trying to figure out how to restart an if statement after a certain delay once it has been satisfied. The project I am working on has a sound activated device (imagine the clapper) that I want to stay on for a specific delay, then turn off and restart the parameters of the loop. Here's my code so far. I tried the continue, break, and was looking into while code but have not used them before. i attached the code (it's modified from the Knock lock starter kit) and I appreciate any help.

Sincerely,
Erik

Clapper.ino (2.98 KB)

Pleas use [ code ] tags instead of attaching the file.

You're description is not quite clear. Do you want to 'reset' some parameters (e.g. the number of knocks), switch the 'switch' off again etc after the delay of 4000ms?

    // if there are three knocks
    if (numberOfKnocks >= 3) {
      // sign is off
      // turn switch on
      digitalWrite(switchPin, HIGH);
      // change status LEDs
      digitalWrite(greenLed, HIGH);
      Serial.println("the screen is on");
      delay (4000);

      //////////////////////////////////////
      // example of resetting
      //////////////////////////////////////

      // switch 'switch' off
      digitalWrite(switchPin, LOW);
      // green off (?)
      digitalWrite(greenLed, LOW);
      // red on (?)
      digitalWrite(redLed, HIGH);
      // reset number of knocks
      numberOfKnocks = 0;

    }