Controlling led via gsm sim900

hi guys …
i have arduino uno and gsm sim900 …
i test it its ok … send and reseved sms …
now i want to Controlling led i uploading these code no error but led doesn’t turn on …
whats the problem please …

#include <SoftwareSerial.h> 
char inchar; // Will hold the incoming character from the GSM shield
SoftwareSerial SIM900(2, 3);

int led1 = 10;
int led2 = 11;
int led3 = 12;
int led4 = 13;

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, HIGH);
  digitalWrite(led2, HIGH);
  digitalWrite(led3, HIGH);
  digitalWrite(led4, HIGH);

  // 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)
  {
    inchar=SIM900.read(); 
    if (inchar=='#')
    {
      delay(10);

      inchar=SIM900.read(); 
      if (inchar=='a')
      {
        delay(10);
        inchar=SIM900.read();
        if (inchar=='0')
        {
          digitalWrite(led1, LOW);
        } 
        else if (inchar=='1')
        {
          digitalWrite(led1, HIGH);
        }
        delay(10);
        inchar=SIM900.read(); 
        if (inchar=='b')
        {
          inchar=SIM900.read();
          if (inchar=='0')
          {
            digitalWrite(led2, LOW);
          } 
          else if (inchar=='1')
          {
            digitalWrite(led2, HIGH);
          }
          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
        }
      }
    }
  }
}

mustafa_abdulwahed7: // Example 55.7

Is this homework?

hhhhhhhhhhhh ... can u help me plz :slightly_frowning_face: :slightly_frowning_face:

:( :(

Have you tried simple test code to flash the LEDs? Without the gsm part?

yes i tested it

You went back and edited out the "// Example 55.7". Does that indicate that perhaps you don't want people to know where it came from? http://tronixstuff.com/2014/01/08/tutorial-arduino-and-sim900-gsm-modules/

Would it not have been polite to inform us?

no but u laughed it .. I do not perfected English in order to discuss why i edit it .. the example in these url http://tronixstuff.com/2014/01/08/tutorial-arduino-and-sim900-gsm-modules/

Why do you think the same code would work for the author and not for you? That is why I suggested testing the LEDs. How did you test them? Please post your LED test code. Also please post a schematic or photo of your circuit.

    inchar=SIM900.read();
    if (inchar=='#')
    {
      delay(10);

If there is data, and the data is a '#', stick your head in the sand for a while. Why?

PaulS:     inchar=SIM900.read();     if (inchar=='#')     {       delay(10);

If there is data, and the data is a '#', stick your head in the sand for a while. Why?

i dont undrestand what you say ...

mustafa_abdulwahed7: i dont undrestand what you say ...

Why are you calling delay when you KNOW that you got good data?

PaulS: Why are you calling delay when you KNOW that you got good data?

i got these code on video on youtube .. now i delete all delay in the code but nothing happend

can be problem on SoftwareSerial SIM900(2, 3) ?

mustafa_abdulwahed7: can be problem on SoftwareSerial SIM900(2, 3) ?

Are you getting any data from the SIM900? If so, the that is not the problem.

PaulS: Are you getting any data from the SIM900? If so, the that is not the problem.

yes i receved sms from sim900 in library example ..

mustafa_abdulwahed7: yes i receved sms from sim900 in library example ..

But you aren't running the library example.

PaulS: But you aren't running the library example.

PaulS: But you aren't running the library example.

what i do now ? thanks for help im student

what i do now ?

Make liberal use of Serial.print().

PaulS:
Make liberal use of Serial.print().

can u give me example ?