Hello i'm having a problem with this GSM sketch below is the example code i found problem is in order for it to light up each led it haves to light up all 4 leds at once by doing #a1b1c1d1 but when i try to just like the third or forth one it doesn't work not sure what to do can someone please help me out.
Trying to light up 4 leds.
#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8);
int onoff=0; // 0 = off, 1 = on
char inchar;
int led1 = 10;
int led2 = 11;
int led3 = 12;
int led4 = 13;
char incoming_char=0;
void setup()
{
Serial.begin(19200); // for serial monitor
SIM900.begin(19200); // for GSM shield
SIM900power(); // turn on shield
delay(5000); // 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);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
}
void SIM900power()
// software equivalent of pressing the GSM shield "power" button
{
digitalWrite(9, HIGH);
delay(1000);
}
void loop()
{
//If a character comes in from the cellular module...
if(SIM900.available() >0)
{
inchar=SIM900.read();
if (inchar=='#')
{
delay(10);
inchar=SIM900.read();
if (inchar=='a')
{
delay(10);
inchar=SIM900.read();
if (inchar=='0')
{
digitalWrite(led1, LOW);
Serial.println("LED 1 OFF");
}
else if (inchar=='1')
{
digitalWrite(led1, HIGH);
Serial.println("LED 1 ON");
}
delay(10);
inchar=SIM900.read();
if (inchar=='b')
{
inchar=SIM900.read();
if (inchar=='0')
{
digitalWrite(led2, LOW);
Serial.println("LED 1 OFF");
}
else if (inchar=='1')
{
digitalWrite(led2, HIGH);
Serial.println("LED 2 ON");
}
delay(10);
inchar=SIM900.read();
if (inchar=='c')
{
inchar=SIM900.read();
if (inchar=='0')
{
digitalWrite(led3, LOW);
}
else if (inchar=='1')
{
digitalWrite(led3, HIGH);
}
delay(10);
inchar=SIM900.read();
if (inchar=='d')
{
delay(10);
inchar=SIM900.read();
if (inchar=='0')
{
digitalWrite(led4, LOW);
}
else if (inchar=='1')
{
digitalWrite(led4, HIGH);
}
delay(10);
}
}
SIM900.println("AT+CMGD=1,4"); // delete all SMS
}
}
}
}
}
I didn't create this sketch but for the most part it works with my sim900 gsm shield can someone please help me out in changing this so i can turn on each led by them self without having to turn them all on at once thank you.