title: (Serial.available() > 0) waits for user input
body: <p>I'm facing problem with user input in Arduino ide. I would like arduino to periodically check if user generate some input string (arduino checks it every 3 seconds), but even if there is no input after 3 seconds (string order="") arduino waits for user input and when I type something then it exit "checkIncomingOrder" function and wait another 3 seconds. I would be gratefull for any advice. My simple code is below:</p>
  
  <pre><code>String order = "";
  int timer;
  
  void setup() {
    Serial.begin(9600);
    timer = 0;
  }
  
  void loop() {
    if (timer == 3)
    {
      checkIncomingOrder();
    }
    else
    {
      delay(1000);
      Serial.println("waiting");
      timer++;
    }
  }
  
  void checkIncomingOrder() {
    if (Serial.available() &gt; 0) { 
      order = Serial.readStringUntil('\n'); 
    }
    if (order == "") {
      return;
    } else {
      Serial.println("Order is: " + order); 
      order = "";
      timer = 0;
    }
  }
  </code></pre>