I want to get incomming call number and compare it Hello i want to get and compare incomming call number, it works but not as I want.
When im calling from good number it print that I was calling form saved number when the number is stop calling i need to do it on start. And else is printing when nobody is calling. How can i do it? Here is my code: 

String d = "";
void setup()
{
  Serial.begin(9600);
  Serial1.begin(9600);
  Serial1.println("AT");
  delay(500);
  Serial1.println("AT+CLIP=1");
  delay(1000);
  Serial1.println("AT+CPIN=1439");
}
void loop()
{ 
 d = Serial1.readString();
 if(d.indexOf("xxxxxxxxx") &gt;=0)
   {
 Serial.println("call is from saved number");
    } else {
       Serial.println("call is not from saved number");
      }
}
The Arduino Serial class member function readString() has a builtin timeout. The function will return on timeout. The default timeout period is 1000 ms. The timeout can be set with setTimeout(). 

The sketch needs to filter out empty lines (timeout). This can be done by adding a check of the string length. See below for an example of checking:

void loop()
{ 
  String d = Serial1.readString(); 
  if (d.length() == 0) return;
  Serial.print(d);
  if (d.indexOf("xxxxxxxxx") &gt;= 0) {
    Serial.println(": call is from saved number");
  } 
  else {
    Serial.println(": call is not from saved number");
  }
}


Cheers!