Delay when a pin gets high

Hi guys im working on a project and is there a way to delay the loop when it goes high? Such as when pin 11 goes high the loop will take 5 mins. in order to start again.

#include <CapacitiveSensor.h>


CapacitiveSensor   cs_4_2 = CapacitiveSensor(7, 6);       // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired

void setup()
{
  cs_4_2.set_CS_AutocaL_Millis(3000);     // turn off autocalibrate on channel 1 - just as an example
  Serial.begin(9600);
}

void loop()
{
  long start = millis();
  long total1 =  cs_4_2.capacitiveSensor(30);
  if (total1 > 50)
 {
    digitalWrite(11, HIGH);
    delay(5000);
   
  } else {
    digitalWrite(11, LOW);
  }

  Serial.print(millis() - start);        // check on performance in milliseconds
  Serial.print("\t");                    // tab character for debug windown spacing

  Serial.println(total1);                  // print sensor output 1
  Serial.print("\t");


  delay(100);                             // arbitrary delay to limit data to serial port
}

Just change that delay(5000) to whatever delay you want.
Not pretty but it gets the job done (it's blocking).

The delay() function delays your code for a time given in a milliseconds. 5 minutes have (560) 300 seconds, or (3001000) 300,000 milliseconds. You can change your code to this:

delay(300000);

Hope this helps!

I need to start the delay after the pin gets high. making the delay into 300000 will set the pin high for 5 minutes I need to idle the Arduino for 5 minutes before next reading starts thanks

Resonance1214:
I need to start the delay after the pin gets high. making the delay into 300000 will set the pin high for 5 minutes I need to idle the Arduino for 5 minutes before next reading starts thanks

That is exactly what the code does. I think that you need to explain your problem in a different way so we can understand,

Currently:
if total1 > 50
set pin high
wait 5 seconds // or 300000; this 'idles' the arduino
else
set pin low

Note:
you have to use pinMode in setup() to make the pin an output.

My best guess would be that he wants to put the thing to sleep (power saving mode), but not too deep sleep or the pin is not kept high.