LED not turning off completely

Hey guys!
Sorry if this is not the right place but im having a little problem controling an led
Here is my code..... Also see video below for a preview on whats going on.....

#include <SPI.h>
#include <Ethernet.h>

int led = 8;
String POST = "";
String SET = "";

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,5,177);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(105);

void setup() {
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
  pinMode(led, OUTPUT);
}


void loop() {
  // listen for incoming clients
  EthernetClient client = server.available();
  digitalWrite(led, HIGH);
  if (client) {
    Serial.println("new client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // it is after the double cr-lf that the variables are
          // read another line!
          String POST = "";
          while(client.available())
          {
            c = client.read();
            // save the variables somewhere
            POST += c;
          }
          if(POST != "")
          {
            if(POST == "led=1"){
              SET = "on";
              Serial.println("on");
            }else{
              SET = "off";
              Serial.println("off");
            }
          }
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connnection: close");
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html><head><title>LED Control</title>");
          client.println("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />");
          client.println("<link href='http://fonts.googleapis.com/css?family=Fjord+One' rel='stylesheet' type='text/css'>");
          client.println("<style>*{font-family:'Fjord One';}body{background-color:#f2f2f2;}h1{color:#222;}</style>");
          client.println("</head><body><h1>LED Control</h1>");
          client.print("<form method='post'>");
          client.print("<input type=\"radio\" name=\"led\" value=\"0\" onclick=\"this.form.submit()\"");
         
          if(SET != "on"){
           client.print(" checked");
          }
         
          client.print(">Off
");
          client.print("<input type=\"radio\" name=\"led\" value=\"1\" onclick=\"this.form.submit()\"");
         
          if(SET == "on"){
           client.print(" checked");
          }
         
          client.print(">On
");
          client.print("</form>");
          client.println("</body></html>");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disonnected");
  }
 
  if(SET == "on"){
    digitalWrite(led, HIGH);
  }else{
    digitalWrite(led, LOW);
  }
}

Hey Kelly,
Can you send me your schematic? I know that sounds silly but let's make sure that your LED is actually being driven properly. What could be happening is on one end you're driving a high side digital pin and on the other you have some floating point voltage, not a ground.

Other than that just do some printing to make sure you hit the 'digitalWrite(pin,LOW)' and if you do, put a delay in there, see if that changes anything.. maybe you're popping out of that logic too quickly and writing HIGH. Though I suspect it's the former, not the latter.

Cheers!

mHo2

Thank you for the response here is pictures of my setup.
https://drive.google.com/file/d/0B18p7MRACKchVlhsUFIwV3RJWHZWd0pLY1VhUGpzQVdhdjJz/edit?usp=sharing

https://drive.google.com/file/d/0B18p7MRACKchTnNzMlRLVVZpWlBWSlNlOTFNYk5lZjZiNWRF/edit?usp=sharing

I note in the middle of your code,           String POST = ""; which makes me suspect you are effectively defining two versions of a variable "POST" with different scope, since you have already defined it at the beginning.

I find your use of string variables as Booleans rather odd.

"Odd" tends to mean "error-prone".

You are always turning the LED on if it needs to be on or not. When it needs to be off it is then turned off and as a result it looks to be on dimly. Get rid of that digital write at the start of the loop function.

Grumpy_Mike:
Get rid of that digital write at the start of the loop function.

Aaaarrrrgh! I missed the dead obvious!