Go Down

Topic: gsm/gprs shield problem (Read 468 times) previous topic - next topic

ahmadalzoubi

hi guys am trying to use the gsm shield to send an sms to arduino and make a led on or off
i used this code

#include "SIM900.h"

#include <SoftwareSerial.h>

#include "sms.h"

SMSGSM sms;

char number[]="3921234567";

char message[180];

char pos;

char *p;

void setup()

{

Serial.begin(9600);

if (gsm.begin(2400))

   Serial.println("\nstatus=READY");

else Serial.println("\nstatus=IDLE");

};

void loop()

{

pos=sms.IsSMSPresent(SMS_UNREAD);

Serial.println((int)pos);

if((int)pos>0&&(int)pos<=20){

   Serial.print("NUOVO MESSAGGIO, POS=");

   Serial.println((int)pos);

   message[0]='\0';

   sms.GetSMS((int)pos,number,message,180);

   p=strstr(message,"testpwd");

   if(p){

     Serial.println("PSWD OK");

     p=strstr(message,"LEDON");

     if(p){

       Serial.println("LED ON");

       digitalWrite(13,HIGH);

     }

     else{

       p=strstr(message,"LEDOFF");

       if(p){

         Serial.println("LED OFF");

         digitalWrite(13,LOW);

       }

     }

   }

   sms.DeleteSMS((int)pos);

}

delay(5000);

};




i downloaded the library right and the sim card is working perfectly but when i send an sms nothing happened it doesnt work pleaseeeeeeeeeeeee help me and my gsm shield is down there

nickgammon

Code tags, please.

Read this before posting a programming question

And get rid of the double-spacing, this isn't an essay.
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

Go Up