hello friends
i am trying to control the LED pin13 by using sim 900
so i first tried it to control LED by serial consol and its working fine i.e if i am sending "ON" led is turning on and for "OFF" via serial consol so everything is fine
now i want to control the same via sms using SIM900 so whenever i am sending sms ON the 13 number LED shoul be ON and viceversa
i am using sim900 gsm library and try to do it but its not working i have modified the code and the code is compiling but led is not glowing when i send on or off
what is the problem in this code??
#include "SIM900.h"
#include <SoftwareSerial.h>
//If not used, is better to exclude the HTTP library,
//for RAM saving.
//If your sketch reboots itself proprably you have finished,
//your memory available.
//#include "inetGSM.h"
//If you want to use the Arduino functions to manage SMS, uncomment the lines below.
#include "sms.h"
SMSGSM sms;
//To change pins for Software Serial, use the two lines in GSM.cpp.
//GSM Shield for Arduino
//www.open-electronics.org
//this code is based on the example of Arduino Labs.
//Simple sketch to send and receive SMS.
int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];
void setup()
{
//Serial connection.
Serial.begin(9600);
Serial.println("GSM Shield testing.");
//Start configuration of shield with baudrate.
//For http uses is raccomanded to use 4800 or slower.
if (gsm.begin(2400)){
Serial.println("\nstatus=READY");
started=true;
}
else Serial.println("\nstatus=IDLE");
pinMode( 13, OUTPUT );
if(started){
//Enable this two lines if you want to send an SMS.
//if (sms.SendSMS("3471234567", "Arduino SMS"))
//Serial.println("\nSMS sent OK");
}
};
void loop()
{
if(started){
//Read if there are messages on SIM card and print them.
if(gsm.readSMS(smsbuffer, 160, n, 20))//n=array for the sender's number //smsBuffer=array for the sender's message
{
Serial.println(smsbuffer);
Serial.println(n);
char inSerial[5];
int i=0;
delay(1000);
if (Serial.available() > 0)
{
while (Serial.available() > 0) {
inSerial[i]=Serial.read(); //read data
i++;
}
inSerial[i]='\0';
Check_Protocol(inSerial);}
}
}
}
void Check_Protocol(char inStr[])
{
Serial.print("Command: ");
Serial.println(inStr);
Serial.println("Check_Protocol");
if(!strcmp(inStr,"ON")) digitalWrite(13,HIGH);
if(!strcmp(inStr,"OFF")) digitalWrite(13,LOW);
}