user38116: Hi dears I'm trying to do project to control app base gsm control by arduino mega 2560 gsm module SIM900A
To send SMS to open Led than reply SMS to give as the status I mean send SMS then I received SMS from GSM module  by this code same time work but same time not work also same time send SMS1111 received SMS2222 status.
I hope it is clear.
#include <SoftwareSerial.h>
#include <string.h>
#include "SIM900.h"
#include <TinyGPS.h>
#include "sms.h"
SoftwareSerial GSMSerial(12, 13);
byte buffer[128]; 
int count = 0; 
const int Led4 = 43;
const int Led1 = 44;
const int Led2 = 45;
const int Led3 = 50;
void SIM900power() 
{
}
void setup() {
    pinMode(Led1, OUTPUT);
  pinMode(Led2, OUTPUT);
  pinMode(Led3, OUTPUT);
  pinMode(Led4, OUTPUT);
  GSMSerial.begin(19200); // the SIM900 baud rate
  Serial.begin(9600); // the Serial port of Arduino baud rate.
  Sim900_Inti();
}
void loop() {
  GSMSerial.listen();
  if (GSMSerial.available()) // If date is comming from from GSM shield)
  {
    while (GSMSerial.available()) // reading data into char array
    {
      buffer[count++] = GSMSerial.read(); // writing data into array
      if (count == 128)break;
    }
    Serial.write(buffer, count); // if no data transmission ends, write         buffer to hardware serial port
Cmd_Read_Act(); //Read the 'COMMAND' sent to SIM900 through SMS
clearBufferArray(); // call clearBufferArray function to clear the storaged data from the array
count = 0; // set counter of while loop to zero
  }
  if (Serial.available()) // if data is available on hardwareserial port ==>     data is comming from PC or notebook
    GSMSerial.println(Serial.read()); // write it to the GPRS shield
}
void clearBufferArray() // function to clear buffer array
{
  delay(1000);
  for (int i = 0; i < count; i++)
  {
    buffer[i] = NULL; // clear all index of array with command NULL
    delay(100);
  }
  for (int n = 0; n < count; n++)
  {
    buffer[n] = NULL; // clear all index of array with command NULL
    delay(100);
  }
  for (int m = 0; m < count; m++)
  {
    buffer[m] = NULL; // clear all index of array with command NULL
    delay(100);
  }
  for (int p = 0; p < count; p++)
  {
    buffer[p] = NULL; // clear all index of array with command NULL
    delay(100);
  }
}
void Sim900_Inti(void)
    {
     GSMSerial.println("AT+CMGF=1"); // Set GSM shield to sms mode
  Serial.println("AT+CMGF=1");
  delay(500);
  GSMSerial.println("AT+CNMI=2,2");
  Serial.println("AT CMGF=1");
  delay(500);
}
void Cmd_Read_Act(void) //Function reads the SMS sent to SIM900 shield.
{
  char buffer_i[128];
  for (int i = 0; i < count; i++)
  {
    buffer_i[i] = char(buffer[i]);
  }
  if (strstr(buffer_i, "1111")) //Comparing password entered with password     stored in program
  {
          digitalWrite(Led1, HIGH);
   SMS_1111();
  }
  char buffer_n[128];
  for (int n = 0; n < count; n++)
  {
    buffer_n[n] = char(buffer[n]);
  }

  if (strstr(buffer_n, "2222")) //Comparing password entered with password     stored in program
  {
          digitalWrite(Led2, HIGH);
   SMS_2222();
  }
      char buffer_m[128];
  for (int m = 0; m < count; m++)
  {
    buffer[m] = char(buffer[m]);
  }
  if (strstr(buffer_m, "3333")) //Comparing password entered with password     stored in program
  {
   digitalWrite(Led3, HIGH);
   SMS_3333();
  }
  char buffer_p[128];
  for (int p = 0; p < count; p++)
  {
    buffer[p] = char(buffer[p]);
  }
  if (strstr(buffer_p, "4444")) //Comparing password entered with password stored in program
      {
    digitalWrite(Led4, HIGH);

   SMS_4444();
  }
}
  void SMS_1111() // complet liter Replay SMS TO Know Led1 Is ON
 {
 }
 void SMS_2222()// complet liter
{
}
void SMS_3333()// complet liter
{
} 
void SMS_4444()// complet liter
{
}>


user972: For the 3333 and 4444 you are doing
buffer[m] = char(buffer[m]);

and 
buffer[p] = char(buffer[p]);

which does nothing.
You probably meant
buffer_m[m] = char(buffer[m]);

and
buffer_p[p] = char(buffer[p]);


38116: <p>Hi dears I'm trying to do project to control app base gsm control by arduino mega 2560 gsm module SIM900A</p>

<p>To send SMS to open Led than reply SMS to give as the status I mean send SMS then I received SMS from GSM module  by this code same time work but same time not work also same time send SMS1111 received SMS2222 status.
I hope it is clear.</p>

<pre><code>#include &lt;SoftwareSerial.h&gt;
#include &lt;string.h&gt;
#include "SIM900.h"
#include &lt;TinyGPS.h&gt;
#include "sms.h"
SoftwareSerial GSMSerial(12, 13);
byte buffer[128]; 
int count = 0; 
const int Led4 = 43;
const int Led1 = 44;
const int Led2 = 45;
const int Led3 = 50;
void SIM900power() 
{
}
void setup() {
    pinMode(Led1, OUTPUT);
  pinMode(Led2, OUTPUT);
  pinMode(Led3, OUTPUT);
  pinMode(Led4, OUTPUT);
  GSMSerial.begin(19200); // the SIM900 baud rate
  Serial.begin(9600); // the Serial port of Arduino baud rate.
  Sim900_Inti();
}
void loop() {
  GSMSerial.listen();
  if (GSMSerial.available()) // If date is comming from from GSM shield)
  {
    while (GSMSerial.available()) // reading data into char array
    {
      buffer[count++] = GSMSerial.read(); // writing data into array
      if (count == 128)break;
    }
    Serial.write(buffer, count); // if no data transmission ends, write         buffer to hardware serial port
Cmd_Read_Act(); //Read the 'COMMAND' sent to SIM900 through SMS
clearBufferArray(); // call clearBufferArray function to clear the storaged data from the array
count = 0; // set counter of while loop to zero
  }
  if (Serial.available()) // if data is available on hardwareserial port ==&gt;     data is comming from PC or notebook
    GSMSerial.println(Serial.read()); // write it to the GPRS shield
}
void clearBufferArray() // function to clear buffer array
{
  delay(1000);
  for (int i = 0; i &lt; count; i++)
  {
    buffer[i] = NULL; // clear all index of array with command NULL
    delay(100);
  }
  for (int n = 0; n &lt; count; n++)
  {
    buffer[n] = NULL; // clear all index of array with command NULL
    delay(100);
  }
  for (int m = 0; m &lt; count; m++)
  {
    buffer[m] = NULL; // clear all index of array with command NULL
    delay(100);
  }
  for (int p = 0; p &lt; count; p++)
  {
    buffer[p] = NULL; // clear all index of array with command NULL
    delay(100);
  }
}
void Sim900_Inti(void)
    {
     GSMSerial.println("AT+CMGF=1"); // Set GSM shield to sms mode
  Serial.println("AT+CMGF=1");
  delay(500);
  GSMSerial.println("AT+CNMI=2,2");
  Serial.println("AT CMGF=1");
  delay(500);
}
void Cmd_Read_Act(void) //Function reads the SMS sent to SIM900 shield.
{
  char buffer_i[128];
  for (int i = 0; i &lt; count; i++)
  {
    buffer_i[i] = char(buffer[i]);
  }
  if (strstr(buffer_i, "1111")) //Comparing password entered with password     stored in program
  {
          digitalWrite(Led1, HIGH);
   SMS_1111();
  }
  char buffer_n[128];
  for (int n = 0; n &lt; count; n++)
  {
    buffer_n[n] = char(buffer[n]);
  }

  if (strstr(buffer_n, "2222")) //Comparing password entered with password     stored in program
  {
          digitalWrite(Led2, HIGH);
   SMS_2222();
  }
      char buffer_m[128];
  for (int m = 0; m &lt; count; m++)
  {
    buffer[m] = char(buffer[m]);
  }
  if (strstr(buffer_m, "3333")) //Comparing password entered with password     stored in program
  {
   digitalWrite(Led3, HIGH);
   SMS_3333();
  }
  char buffer_p[128];
  for (int p = 0; p &lt; count; p++)
  {
    buffer[p] = char(buffer[p]);
  }
  if (strstr(buffer_p, "4444")) //Comparing password entered with password stored in program
      {
    digitalWrite(Led4, HIGH);

   SMS_4444();
  }
}
  void SMS_1111() // complet liter Replay SMS TO Know Led1 Is ON
 {
 }
 void SMS_2222()// complet liter
{
}
void SMS_3333()// complet liter
{
} 
void SMS_4444()// complet liter
{
}&gt;
</code></pre>
 972: <p>For the <code>3333</code> and <code>4444</code> you are doing</p>

<pre><code>buffer[m] = char(buffer[m]);
</code></pre>

<p>and </p>

<pre><code>buffer[p] = char(buffer[p]);
</code></pre>

<p>which does nothing.</p>

<p>You probably meant</p>

<pre><code>buffer_m[m] = char(buffer[m]);
</code></pre>

<p>and</p>

<pre><code>buffer_p[p] = char(buffer[p]);
</code></pre>
