Arduino Serial.available

How can I break while(!Serial.available()) loop ?

void waitSerial(){
Serial.print("Current Param are..");
printtemp();
Serial.println(" set Temp Humid now? Y/N");
while (!Serial.available())
delay(10);
//Serial.println(Serial.read());
if (Serial.read() == 'Y' || Serial.read() == 'y')
{

Serial.read();
setTemp();
delay(500);
Serial.print("The current Temp Humid are now: ");
printtemp();
}
}

Why do you need it at all?

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

...R

Something like this

  unsigned long startTime = millis();
  unsigned long period = 2000;
  Serial.println("Waiting");
  while (!Serial.available())
    if (millis() - startTime >= period)
    {
      Serial.println("time's up");
      break;
    }
  Serial.println("Finished");