nclude #include //////////////////////////////////////////////////////////////////////// //CONFIGURE //////////////////////////////////////////////////////////////////////// byte server[] = { 24,31,137,35 }; //ip Address of the server you will connect to //The location to go to on the server //make sure to keep HTTP/1.0 at the end, this is telling it what type of file it is String location = "/learn_php/finals/stat.php"; byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //////////////////////////////////////////////////////////////////////// EthernetClient client; char inString[32]; // string for incoming serial data int stringPos = 0; // string index counter boolean startRead = false; // is reading? void setup(){ pinMode(6, OUTPUT); Ethernet.begin(mac); Serial.begin(9600); } void loop(){ String pageValue = connectAndRead(); //connect to the server and read the output Serial.println(pageValue); //print out the findings. String inSstring = String(inString); //converts the c variable to a string to work with. String Blue_ID = String("on"); //Sets up a varible to compare the led to, i'm using a variable because I may make something cooler with this later if(inSstring == Blue_ID){ Serial.print("Pass"); digitalWrite(6, HIGH); Serial.print("..."); //all debug below here Serial.print("The Site Prints: "); Serial.print(inSstring); Serial.print("..."); Serial.print("Compared to: "); Serial.print(Blue_ID); Serial.println(""); } if(inSstring != Blue_ID){ //This is for when it does not compare correctly Serial.print("Fail"); digitalWrite(6, LOW); Serial.print("..."); //all debug below here Serial.print("The Site Prints: "); Serial.print(inSstring); Serial.print("..."); Serial.print("Compared to: "); Serial.print(Blue_ID); Serial.println(""); } delay(500); //wait .5 seconds } String connectAndRead(){ Serial.print("connecting..."); //connect to the server //port 80 is typical of a www page if (client.connect(server, 80)) { Serial.println("connected"); client.print("GET "); client.println(location); client.println(); //Connected - Read the page return readPage(); //go and read the output }else{ return "connection failed"; } } String readPage(){ //read the page, and capture & return everything between '<' and '>' stringPos = 0; memset( &inString, 0, 32 ); //clear inString memory while(true){ if (client.available()) { char c = client.read(); if (c == '<' ) { //'<' is our begining character startRead = true; //Ready to start reading the part } else if(startRead){ if(c != '>'){ //'>' is our ending character inString[stringPos] = c; stringPos ++; } else{ //got what we need here! We can disconnect now startRead = false; client.stop(); client.flush(); Serial.print("The Site Says Returns: "); return (inString); Serial.print("..."); }}}}}