SMS Receiving problem - Arduino Uno and SIM900A GSM Module My intention is to control an LED according to the content of the SMS received. For example, if the SMS is "ON", turn on the LED and if it is "OFF", turn it off. I referred many sites and got the below code. 
The digital pins 9 and 10 are used instead of Rx and Tx to avoid the code uploading problem.

(I have kept the different versions of AT commands commented in the code because I'm not sure which one is correct. With the current one, I'm able to get some kind of output which I've mentioned after the code.)

#include &lt;SoftwareSerial.h&gt;
SoftwareSerial mySerial(9, 10);

char msg;
void setup()
{
  Serial.begin(9600);
  mySerial.begin(9600);   // Setting the baud rate of GSM Module  
  delay(1000);
  //mySerial.print("AT+CMGF=1r"); // set SMS mode to text
  mySerial.print("AT+CMGF=1\r");  // set SMS mode to text

  delay(100);
  //mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
  //mySerial.print("AT+CNMI=2,2,0,0,0r");

  mySerial.print("AT+CNMI=1,2,0,0,0\r"); // AT Command to receive a live SMS
  delay(100);
  Serial.println("Ready");
}

void loop() 
{
  if (mySerial.available()&gt;0)
  {
    msg=mySerial.read();
    Serial.print(msg);
  }
}


This is the output I'm getting..

Ready
AT+CMGF=1
AT+CNMI=1,2,0,0,0

OK

+CMTI: "SM",31

+CMTI: "SM",32

+CMTI: "SM",33

+CMTI: "SM",34


The issue is, I'm not able to retrieve the message content. What I'm getting is

"+CMTI: "SM",31"

"+CMTI: "SM",32" 

and the number keeps on incrementing. (33, 34 and so on). 

I do understand that I have to parse the message to get the exact content, but here I'm not getting the content at all. What exactly should I do to get the SMS content? Could anybody help me to solve this?

One more thing, the GSM module I'm using is a SIM900A type (from elementzonline.com). It's not a shield type, so I've made connections using wires; the Rx, Tx connections and the ground one.

(Sorry for the bad explanation, I'm a complete noob in Arduino, a hobbyist.) 

Thanks in advance.
Instead of using At commands use the GSM library of Arduino it easier to understand and implement.
the code to recieve SMS

    #include &lt;GSM.h&gt;

    // PIN Number for the SIM
    #define PINNUMBER "" //sim pin incase the sim is kept locked 

    // initialize the library instances
    GSM gsmAccess;
    GSM_SMS sms;

    // Array to hold the number a SMS is retreived from
    char senderNumber[20];

    void setup() {
      // initialize serial communications and wait for port to open:
      Serial.begin(9600);
      while (!Serial) {
        ; // wait for serial port to connect. Needed for native USB port only
      }

      Serial.println("SMS Messages Receiver");

      // connection state
      boolean notConnected = true;

      // Start GSM connection
      while (notConnected) {
        if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
          notConnected = false;
        } else {
          Serial.println("Not connected");
          delay(1000);
        }
      }

      Serial.println("GSM initialized");
      Serial.println("Waiting for messages");
    }

    void loop() {
      char c;

      // If there are any SMSs available()
      if (sms.available()) {
        Serial.println("Message received from:");

        // Get remote number
        sms.remoteNumber(senderNumber, 20);
        Serial.println(senderNumber);

        // An example of message disposal
        // Any messages starting with # should be discarded
        if (sms.peek() == '#') {
          Serial.println("Discarded SMS");
          sms.flush();
        }

        // Read message bytes and print them
        while (c = sms.read()) {
          Serial.print(c);
        }

        Serial.println("\nEND OF MESSAGE");

        // Delete message from modem memory
        sms.flush();
        Serial.println("MESSAGE DELETED");
      }

      delay(1000);

    }