Help regarding Ardino Uno with SIM900A to send SMS.

Hi

I am working on the arduino uno with sim900A model,i am not able to get reply from SIM900 model to arduino serial monitor nor able to send an SMS.Bellow is my code.Please give me solution.

#include<SoftwareSerial.h>

SoftwareSerial mySerial(3, 2); // RX, TX pins

int led= 13;
String str;
//char str;

// serial communication settings

void setup()
{

Serial.begin(9600);
mySerial.begin(9600); // setting the buad rate as 9600
pinMode(led,OUTPUT); // initialize the digital pin as an output.
Serial.println("GSM communication initialization");
mySerial.println("AT"); // activating the gsm module.
delay(500);
mySerial.println("AT+CMGF=1"); // setting the gsm module to sms mode.
delay(500);
Serial.println("serial communication begins");

}

void loop()
{

while(mySerial.available() > 0)
{
str = mySerial.readString();
Serial.print(str);
int data=str.indexOf("hello");
mySerial.println(str);

if(data!=-1)
{
mySerial.println("AT+CMGS="9902062107""); // mobile number
delay(500);
mySerial.println("hello"); // Message contents
delay(500);
mySerial.write(byte(26)); // (signals end of message)
delay(500);
}
}
}

Please mark your code up using code tags, it makes it easier to read (# button, you can edit your post.)

Does the SIM900 send a message without all the string read code at the start of the loop? I'm not certain what you are expecting to happen with the following code in any case.

        str = mySerial.readString();
       Serial.print(str);
       int data=str.indexOf("hello");
      mySerial.println(str);