help reg LOOP stop

im a fresher in arduino. i need a loop stop code.. if input HIGH.. Attached for your ref pls help me

const int sensorIn = A0;
const int sensor2In = A1;
int mVperAmp = 100; 
int LED =9;
int Relay = 12;
int IP = 7;
int IPState = 0;
double Voltage = 0;
double VRMS = 0;
double AmpsRMS = 0;

void setup(){ 
 Serial.begin(9600);
 pinMode (LED,OUTPUT);
 pinMode (IP,INPUT_PULLUP);
 pinMode(Relay,OUTPUT);
}

void loop(){
 IPState = digitalRead(IP);
 if(IPState == HIGH) //   i need a loop stop code in this place ..  (if IPstate == low) run the loop after 10 seconds.
                           loop should start after 10 sec delay if IPstate ==low...   if input HIGH loop should stop until input get low 
 

 
 Voltage = getVPP();
 VRMS = (Voltage/2.0) *0.707; 
 AmpsRMS = (VRMS * 1000)/mVperAmp;
 Serial.print(AmpsRMS);
 Serial.println(" Amps RMS");
 
 
}
float getVPP()
{
  float result;
  
  int readValue;            
  int maxValue = 0;         
  int minValue = 1024;         
  
   uint32_t start_time = millis();
   while((millis()-start_time) < 1000) 
   {
       readValue = analogRead(sensorIn);
      
       
      
       if (readValue > maxValue) 
       {
          
           maxValue = readValue;
       }
       if (readValue < minValue) 
       {
          
           minValue = readValue;
       }
   }
   
  
   result = ((maxValue - minValue) * 5.0)/1024.0;
   Serial.println(result);
   if (result>1.0){
    digitalWrite (LED,HIGH);
    delay(100);
    digitalWrite (Relay,HIGH);
    delay (100);
   }
    else
    {
      digitalWrite(LED,LOW);
      delay(100);
      digitalWrite(Relay,LOW);
      delay(100);
    }


  float result2;
  
  int readValue2;            
  int maxValue2 = 0;         
  int minValue2 = 1024;
   
   uint32_t start_time1 = millis();
   while((millis()-start_time1) < 1000)        
  
   
   {
      
       readValue2 = analogRead(sensor2In);
       
      
       if (readValue2 > maxValue2) 
       {
          
           maxValue2 = readValue2;
       }
       if (readValue2 < minValue2) 
       {
          
           minValue2 = readValue2;
       }
   }
   
  
   result2 = ((maxValue2 - minValue2) * 5.0)/1024.0;
   Serial.println(result2);
   if (result2>0.5 ){
    digitalWrite (LED,HIGH);
    delay(100);
    digitalWrite(Relay,HIGH);
    delay(100);
   }
    else
    {
      digitalWrite(LED,LOW);
      delay(100);
      digitalWrite(Relay,LOW);
      delay(100);
    }

    
   return result;
 }

Kumar1984:
im a fresher in arduino. i need a loop stop code.. if input HIGH..

What input are you referring to?

What exactly do you want to happen when it is HIGH?

If you just want the complete program to stop then put it into an infinite loop like this

while (true);

...R

void loop()
{
  static unsigned long runStartTime = 0;


  // Do nothing until the IP pin goes LOW
  while (digitalRead(IP) == HIGH)
  {
    runStartTime = millis();
    return;
  }
  
  // Now that the IP pin has gone LOW, do nothing for 10 seconds
  if (millis() - runStartTime < 10000)
    return;

Thank you very much for your valuable reply.. yes i got it