Uno + Ethernet Shield to PHP

PaulS:

char server[] = "192.168.0.2/TA/user_room.php";    // name address for Google (using DNS)

Does that completely useless, incorrect comment really serve any purpose?

    client.println("GET /search?q=arduino HTTP/1.1");

After connecting to some bogus server (or trying to, anyway), does this GET request really make sense? It's fine if you are talking to google. It's useless when you try to talk to some other server.

I made a new code. For the example, I tried to control led using checkbox on my php. Serial monitor shows that the arduino and php are connected. But when I click the checkbox, nothing happens with the led.

Arduino code:

#if ARDUINO > 18
#include <SPI.h> // needed for Arduino versions later than 0018
#endif
#include <Ethernet.h>
#include <TextFinder.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 0, 2 }; // my php web
byte gateway[] ={ 192, 168, 0, 1 }; // router ip
byte subnet[] ={ 255, 255, 255, 0 };
//byte server[] = {209,85,229,147 }; // google
char server[] = "192.168.0.2/TA/user_room.php";  
EthernetClient client;
TextFinder finder( client );
float value;

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

  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip, gateway);
  }
  // give the Ethernet shield a second to initialize:
  delay(1000);
  Serial.println("connecting...");

  // if you get a connection, report back via serial:
  if (client.connect(server, 80)) {
    Serial.println("connected");
    // Make a HTTP request:
    client.println("GET /192.168.0.2/TA/coba_led.php?LED2=2 HTTP/1.1"); //the ip when checkbox was clicked
    //client.println("HOST: 192.168.0.2/TA/user_room.php");
    client.println("Connection: close");
    client.println();
  }
  else {
    // kf you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}

void loop()
{
EthernetClient client;
if (client) {
TextFinder finder(client );
while (client.connected()) {
if (client.available()) {
// counters to show the number of pin change requests
int digitalRequests = 3; // output pin
if( finder.find("GET /") ) {
// find tokens starting with "pin" and stop on the first blank line
while(finder.findUntil("2", "\n\r")){ //value of led at button
char type = client.read(); 
int pin = finder.getValue();
int val = finder.getValue();
if( type == '2') { 
Serial.print("Digital pin ");
pinMode(3, OUTPUT);
digitalWrite(pin, HIGH);
digitalRequests++;
}
else {
Serial.print("Unexpected type ");
Serial.print(type);
}
Serial.print(pin);
Serial.print("=");
Serial.println(val);
}
}
Serial.println();
// the findUntil has detected the blank line (a lf followed by cr)
// so the http request has ended and we can send a reply
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
break;
}
}
// give the web browser time to receive the data
delay(1);
client.stop();
}
}