LED on Arduino won't turn on / off based on condition

I have an Arduino UNO R3 that reads a specific value from my Web Page.

I have an LED attached to the PIN 13 & GND of my Arduino.

When the Arduino reads 1 from my Web Page, it should turn the LED ON. When it reads 0, it should turn it off.

Following is the code for that:

#include "SIM900.h"
#include <SoftwareSerial.h>
#include "inetGSM.h"


InetGSM inet;

#define ledPin 13

char msg[165];
char store[2];
char a;
char b;

char* disp;

boolean started=false;

void setup()
{
      pinMode(ledPin, OUTPUT);
      digitalWrite(ledPin, LOW);
     //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");

     if(started) 
     {
          //GPRS attach, put in order APN, username and password.
          //If no needed auth let them blank.
          if (inet.attachGPRS("TATA.DOCOMO.INTERNET", "", ""))
               Serial.println("status=ATTACHED");
          else Serial.println("status=ERROR");
          delay(1000);



          //TCP Client GET, send a GET request to the server and
          //save the reply.

          //Print the results.


     }
}

void loop()
{
  inet.httpGET("www.boat.esy.es", 80, "/retrieve.php", msg, 165);
  disp = strstr(msg,"\r\n\r\n");
  disp = disp+4;
  a = disp[0];
  b = disp[1];
  Serial.println(b);
  if(b=='1')
  { 
    digitalWrite(ledPin, HIGH);
  }
  if(b=='0');
  {
    digitalWrite(ledPin, LOW);
  }
}

Problem here is, when I disable the digitalWrite(ledPin,LOW), that is when I comment it out, the LED turns on & stays that way.

But the moment I enable it & load the code on my Arduino, it won't even turn on.

I'm wondering if it's a logical error or something else. Because the turning on & off of the LED depends completely on the conditions being satisfied. And for now, my Web Page returns only 1, hence the LED should stay on. But when I include both digitalWrite(ledPin, HIGH) and digitalWrite(ledPin, LOW) in the same code and run it, it doesn't work. I can see the Serial printing out the messages associated with the LED ON, but I don't see the LED turning ON.

Thank You for your time!!
______________________________________________________nha khoaimplant
Any ideas would be appreciated

Have you the LED installed the correct way round.

Try it with a different I/O pin because pin 13 is for the onboard LED and behaves a bit differently.

Can you get the LED to work as you want with a simple blink program?

...R
PS. The Bar Sport section is for jokes and other stupid stuff :slight_smile:

 if(b=='0');

Oops