title: Arduino: while (Serial.available()==0) gives input
body: <p>I am trying to input GPS coordinate into the serial monitor to use in my drone project</p>
  
  <p>However, whenever I try to input GPS coordinate, it automatically writes one of the GPS coordinates without my input.  For example, GPS latitude is shown as 0.00, but the program waits for GPS Longitude info.</p>
  
  <p>For a detailed situation please look at the picture attached.</p>
  
  <p><a href="https://i.stack.imgur.com/kgRds.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kgRds.jpg" alt="enter image description here"></a></p>
  
  <pre><code>int GPSNumCor;
  
  void setup() {
    // put your setup code here, to run once:
    Serial.begin (115200);
    Serial.print("What is the number of your GPS Coordinate?  ");
    while (Serial.available() == 0);
    GPSNumCor = Serial.parseInt();
    Serial.println(GPSNumCor);
    delay (200);
    float GPSLat[GPSNumCor], GPSLon[GPSNumCor];
    for (int i = 0; i &lt; GPSNumCor; i++)
    {
      if (i == 0)
      {
        Serial.println("What is your 1st GPS Coordinate");
      }
      if (i == 1)
      {
        Serial.println("What is your 2nd GPS Coordinate");
      }
      if (i == 2)
      {
        Serial.println("What is your 3rd GPS Coordinate");
      }
      if (i &gt; 2)
      {
        Serial.print("What is your ");
        Serial.print(i + 1);
        Serial.println(" th GPS Coordinate");
      }
      delay(200);
      Serial.print ("Latitude: ");
      while (Serial.available() == 0);
      GPSLat[i] = Serial.parseFloat();
      Serial.println(GPSLat[i]);
      Serial.print("Longitude: ");
      while (Serial.available() == 0);
      GPSLon[i] = Serial.parseFloat();
      Serial.println(GPSLon[i]);
    }
  }
  </code></pre>
  
  <p>It has to wait for all input until I make an input to the program, but it does not wait.</p>
  
  <p>I know while (Serial.available()==0) is a way to go, but I do not know why it would not work.</p>