Problem in receiving message using GSM I have made modification of the code from GSM Modem with Arduino UNO

I have found a related question but it does not solve my problem. The message and command is printed in serial terminal of Arduino IDE but message is not received in the registered number. I am using SIM900A GSM module. Kindly direct me where I have gone wrong.

int pin = 4;
int val = 0; 
void setup()
{
  pinMode(pin, INPUT);   
  Serial.begin(9600);  //Baud rate of the GSM/GPRS Module 
  Serial.print("\r");
  delay(1000);                  
  Serial.print("AT+CMGF=1\r");    
  delay(1000);
  Serial.print("AT+CMGS=\"+919********5\"\r");    
  delay(1000);

}
void loop()
{
  delay(1000);
  val = digitalRead(pin);
  delay(1000);
  if(val==1)
  {
    delay(1000);
    Serial.print("Found an object\r");   
    delay(1000);
    Serial.write(0x1A);
    delay(1000); 
  }
  val=0;
  delay(1000);

 }
If you want to use the Console monitor and the GSM at the same time, you need to use different pins to separate the communication streams.

Typically the console serial monitor is attached to Serial.*, while GSM modules are attached using SoftwareSerial to other pins.  See https://arduino.stackexchange.com/a/1195/6628 for an example.