PIR and gsm shield

i want to control led throught sms when i send sms pompeon led should turn on and when i send sms pompeoff led should turn off and when led turn off PIR sensor should start work
sometime sms part working fine and sometime no i dont know why but PIR sensor is not working i have attached code down there

sketch_may04a.ino (3.56 KB)

//#include "SIM900.h"
#include <SoftwareSerial.h>
#include "sms.h"
#include "gsm.h"
//#include "string.h"

#define DEBUG_CODE_ON
#define DEBUG_ACTION_ON

SMSGSM sms;


boolean started=false;
boolean startSMS=false;
char smsbuffer[160];
char n_in[16];
char n_ref[12] = "60172543861";
char  msg[1];
char pompe_on[160] = "Pompeon";
char pompe_off[160] = "Pompeoff";
char vanne_on[160] = "Vanneon";
char vanne_off[160] = "Vanneoff";
int swtch=13;
int PIRSensor=2;


void setup() 
{
  
  // digit
  pinMode(swtch, OUTPUT);
  pinMode(PIRSensor, INPUT);

  //Serial connection.
  Serial.begin(9600);
  Serial.println("GSM Shield testing.");

  // GSM START
  if (gsm.begin(9600))
  {
    Serial.println("\nstatus=READY");
    started=true;  
  }
  else Serial.println("\nstatus=IDLE");
  
  if(started){
    #ifdef DEBUG_CODE_ON
    Serial.println("mise en ligne");
    #endif
    
    gsm.SimpleWriteln("AT+CMEE=2");
    delay(5000);
    #ifdef DEBUG_CODE_ON
    Serial.print("AT+CMEE=2");
    gsm.WhileSimpleRead();
    #endif
//
// PIN CODE
//
    #ifdef DEBUG_CODE_ON
    Serial.println("PIN CODE");
    #endif

 
//if (gsm.SendATCmdWaitResp("AT+CPIN ?", 1000, 100, "READY", 5) != 1 ) 
//      {
      gsm.SimpleWriteln("AT+CPIN=2343");
      delay(5000);
      #ifdef DEBUG_CODE_ON
      Serial.print("AT+CPIN=####");
      gsm.WhileSimpleRead();
      #endif
//      }

//
// INIT FOR SEND SMS
//
    gsm.SimpleWriteln("AT+CLIP=1");
    delay(500);
    #ifdef DEBUG_CODE_ON
    Serial.print("AT+CLIP=1");
    gsm.WhileSimpleRead();
    #endif

   
    gsm.SimpleWriteln("AT+CSCA ?");
    delay(5000);
    #ifdef DEBUG_CODE_ON
    Serial.print("AT+CSCA ?");
    gsm.WhileSimpleRead();
    #endif
       
    gsm.SimpleWriteln("AT+CMGF=1");
    delay(5000);
    #ifdef DEBUG_CODE_ON
    Serial.print("AT+CMGF=1");
    gsm.WhileSimpleRead();
    #endif

//
// CMD LOW
//
    #ifdef DEBUG_ACTION_ON
    Serial.println("INIT PUMP");
    #endif
    digitalWrite(swtch, LOW);
    
   

  }

};
void PIRON(){

if(digitalRead(PIRSensor)==HIGH){   // read the input pin
  digitalWrite(swtch, HIGH);      // sets the LED to the button's value
  delay(1000);    
digitalWrite(swtch, LOW);   // delay in milisecond. 3000 = 3 second
  }
}
void loop() 
{

if(started)
    {
//    
// READ SMS
//
    #ifdef DEBUG_ACTION_ON
     Serial.println("Wait Read sms");
    #endif

    if(gsm.readSMS(smsbuffer, 16, n_in, 12))
    {
      #ifdef DEBUG_ACTION_ON
      Serial.println(n_in);
      Serial.println(smsbuffer);
      #endif
      //
      // filter num gsm
      //
      if (memcmp(n_in,n_ref,11)==0)
      {
        #ifdef DEBUG_ACTION_ON
        Serial.println("Sender ok");
        #endif
        // ok
        startSMS=true;
      }
    }
    
  
   //  
   // Action
   //
     if (startSMS){

  //
  // pump 
  //


    if (memcmp(smsbuffer,pompe_on,7)==0) 
    {
      digitalWrite(swtch, HIGH); 
      #ifdef DEBUG_ACTION_ON
      Serial.println("Pump On"); 
      #endif
    }
    
    if (memcmp(smsbuffer,pompe_off,7)==0) 
    {
      digitalWrite(swtch, LOW);
      PIRON();
      #ifdef DEBUG_ACTION_ON
      Serial.println("Pump Off");
      #endif
    }

//
// valve
//

/*

    if (memcmp(smsbuffer,vanne_on,7)==0) 
    {
      digitalWrite(12, LOW);
      #ifdef DEBUG_CODE_ON
      Serial.println("Valve On");
      #endif
    }
        if (memcmp(smsbuffer,vanne_off,7)==0) 
    {
      digitalWrite(12, LOW);
      #ifdef DEBUG_CODE_ON
      Serial.println("Valve Off");
      #endif
    }

*/

     startSMS=false;
     // clear SMS
     gsm.SimpleWriteln("AT+CMGL=\"REC UNREAD\",0");

     }

      }
      delay(500);
 


};

Please don't cross-post.

i hope this question will be answered. im hopping for this one. thesame question for me. pls send me a message if you solved it. thank you very much.

your problem is to complex while mine isnt.
im new in gsm shield. pls bro. can you send the code for

if i send "on" to gsm shield from my phone the led turns on.
the gsm shield will notify and text you back if the led is turned on.

if i send "off" to gsm shield from my phone the led turns off.
the gsm shield will notify and text you back if the led is turned off.

i think, you are the only person who can answer me back.