Send SMS from GSM modem using Arduino

I am trying to interface a GSM SIM900A modem with my arduino to send sms when required. I started off with a basic code to just send one sms(to test the modem) but it did not work. I partially believe the problem is in the modem but i am putting up my code here. Someone please tell me if there is something wrong with it or if i may try anything else before deciding that the modem is faulty.

void setup()
{
  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=\"+919445764778\"\r");    //Number to which you want to send the sms
  delay(1000);
  Serial.print("Test SMS\r");   //The text of the message to be sent
  delay(1000);
  Serial.write(0x1A);
  delay(1000); 
}
void loop()
{
}

I connected the Tx and Rx od the modem with the Rx and Tx of my arduino UNO respectively(i tried the other way also). Powered the modem properly(i am getting a dial tone when i am calling that number). When i am running this code, the messages are coming up on the serial monitor as expected but i am not receiving the SMS.

I tried this simple program with the arduino to check if the modem was responding with an “OK” after i fed in “AT”. Is this program allright? I did not get any result with it.

void setup()
{
pinMode(13, OUTPUT);
Serial.begin(9600);
}
void loop()
{
int i;
char a[2];
Serial. print(“AT\r”);
for(i = 0; i <2; i++)
{
a[i] = Serial.read();
delay(50);
}
if(a[0] == 'O' && a[1] == 'K')
{
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
}

Someone help me out here please. :frowning: