#include <SoftwareSerial.h>
//String1= String inchar; // Will hold the incoming character from the GSM shield
SoftwareSerial SIM900(7, 8);
int led1 = 10;
int led2 = 11;
int led3 = 12;
int led4 = 13;
String string1 ;
void setup()
{
Serial.begin(19200);
// set up the digital pins to control
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
// wake up the GSM shield
SIM900power();
SIM900.begin(19200);
delay(20000); // give time to log on to network.
SIM900.print("AT+CMGF=1\r"); // set SMS mode to text
delay(100);
SIM900.print("AT+CNMI=2,2,0,0,0\r");
// blurt out contents of new SMS upon receipt to the GSM shield's serial out
delay(100);
Serial.println("Ready...");
}
void SIM900power()
// software equivalent of pressing the GSM shield "power" button
{
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(7000);
}
void loop()
{
//If a character comes in from the cellular module...
if(SIM900.available() >0)
{
string1=String(SIM900.read());
if (string1.equals(".led1 off"))
{
digitalWrite(led1, LOW);
}
if (string1.equals(".led1 on"))
{
digitalWrite(led1, HIGH);
}
if (string1.equals(".led2 off"))
{
digitalWrite(led2, LOW);
}
if (string1.equals(".led2 on"))
{
digitalWrite(led2, HIGH);
}
if (string1.equals(".led3 off"))
{
digitalWrite(led3, LOW);
}
if (string1.equals(".led3 on"))
{
digitalWrite(led3, HIGH);
}
if (string1.equals(".led4 off"))
{
digitalWrite(led4, LOW);
}
if (string1.equals(".led4 on"))
{
digitalWrite(led4, HIGH);
}
}
SIM900.println("AT+CMGD=1,4"); // delete all SMS
}
i want to control 4 leds on and off using sms the above code is not working can any one identify me where is the problem ?