title: How to stop void loop in arduino?
body: <p>I am trying to make the void loop in arduino code to just run only once. What is the algorithm or command for this? 
  My code is:</p>
  
  <pre><code>#include &lt;String.h&gt;
  #include &lt;SoftwareSerial.h&gt;
  #include &lt;ESP8266WiFi.h&gt;
  SoftwareSerial s(D6,D5); // (Rx, Tx)
  String saavi="ABCD";
  String saavi1="123456789";
  String shab;
  String arr[4];
  int a=0;
  String arr1[10];
  const char* shab1="";
  const char* shab3="";
  String shab2;
  std::string str;
  int i,j,k,x;
  bool check=true;
  void setup() {
   s.begin(9600);
   Serial.begin(9600);
   Serial.print("enter ssid: ");
  }
  void loop() {
      s.write("s");
      while(s.available() &gt;0) {
      char data=s.read();
      shab += data;
      Serial.print(data);
     }
      if(shab.length()==4) {
      for(i=0;i&lt;shab.length();i++)
      {
        arr[i]=shab.substring(i);
      }
       shab1 = arr[0].c_str();
       //Serial.println(shab1);
        if(arr[0] == saavi)
      { Serial.println();
        Serial.println("correct ssid");
        Serial.println("Enter ur password");
        delay(2000);
        s.write("s");
      while(s.available() &gt;0) {
      char data1=s.read();
      shab2 += data1;
      Serial.print(data1);
      if(shab2.length()==9) {
      for(k=0;k&lt;shab2.length();k++)
      {
        arr1[k]=shab2.substring(k);
      }
      shab3 = arr1[0].c_str();
      //Serial.println(shab3);
      if(arr1[0] == saavi1)
      {
        Serial.println();
      Serial.println("correct password");
      delay(3000);
      Serial.println("Connecting to wifi: ");
      delay(2000);
      Serial.println(shab1);
      Serial.flush();
      WiFi.begin(shab1,shab3);
       while (WiFi.status() != WL_CONNECTED) 
    {
      delay(500);
      Serial.print(".");
    }
      Serial.println(" IP address: ");
      Serial.print(WiFi.localIP());
      delay(2000);
      break;
      }
      else
      {
      Serial.print("wrong password");
      }
      } 
      }
      }else {
        Serial.print("Wrong ssid");
       }  
   }
  
  }
  </code></pre>
  
  <p>When I run this code it shows "correct ssid and enter ur password" again and again. This just does not stop. So, how to make void loop run only once in this code. Can anyone please help me?</p>
  
  <p>Just one more doubt.
  In void loop line no. 18, i have added a delay of 2000ms because without adding delay the next line in the code i.e. "while(s.available() >0) " does not work. This while command is so quick that it needs some delay so that i can enter the password"123456789". What should i do so that this while loop does not work so quick until i press a key from my keypad? Please help!!</p>