You know I don't think I do. Thanks! As I say it was a copy from a demo code I found, then again I dont see where they did either...
Here is there code
//zoomkat 6-13-15
//get submit box code
//for use with IDE 1.0
//open serial monitor to see what the arduino receives
//use the \ slash to escape the " in the html or use a '
//address will look like http://192.168.1.102:84 when submited
//for use with W5100 based ethernet shields
//Powering a servo from the arduino usually *DOES NOT WORK*.
#include <SPI.h>
#include <Ethernet.h>
#include <Servo.h>
Servo myservo; // create servo object to control a servo
//int n; //value to write to servo
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = {
192, 168, 1, 102 }; // ip in lan
byte gateway[] = {
192, 168, 1, 1 }; // internet access via router
byte subnet[] = {
255, 255, 255, 0 }; //subnet mask
EthernetServer server(84); //server port
String readString, newString;
//////////////////////
void setup(){
//start Ethernet
Ethernet.begin(mac, ip, gateway, gateway, subnet);
server.begin();
//enable serial data print
Serial.begin(9600);
myservo.writeMicroseconds(1500); //set initial servo position if desired
myservo.attach(7, 500, 2500); //the pin for the servo control, and range if desired
Serial.println("server text box servo test"); // so I can keep track of what is loaded
}
void loop(){
// Create a client connection
EthernetClient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();
//read char by char HTTP request
if (readString.length() < 100) {
//store characters to string
readString += c;
//Serial.print(c);
}
//if HTTP request has ended
if (c == '\n') {
///////////////
Serial.print(readString); //see what was captured
//now output HTML data header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.println("<HTML>");
client.println("<HEAD>");
client.println("<TITLE>Arduino GET test page</TITLE>");
client.println("</HEAD>");
client.println("<BODY>");
client.println("<H1>HTML form GET example</H1>");
client.println("<FORM ACTION='/' method=get >"); //uses IP/port of web page
client.println("Set servo position: <INPUT TYPE=TEXT NAME='LED' VALUE='' SIZE='25' MAXLENGTH='50'>
");
client.println("<INPUT TYPE=SUBMIT NAME='submit' VALUE='Send servo position'>");
client.println("</FORM>");
client.println("
");
client.println("</BODY>");
client.println("</HTML>");
delay(1);
//stopping client
client.stop();
/////////////////////
if (readString.length() >0) {
//Serial.println(readString); //prints string to serial port out
int pos1 = readString.indexOf('=');
int pos2 = readString.indexOf('&');
newString = readString.substring(pos1+1, pos2);
Serial.print("newString is: ");
Serial.println(newString);
int n = newString.toInt();
Serial.print("The value sent is: ");
Serial.println(n);
readString=""; //clears variable for new input
newString=""; //clears variable for new input
// auto select appropriate value
if(n >= 500)
{
Serial.print("writing Microseconds: ");
Serial.println(n);
myservo.writeMicroseconds(n);
Serial.println();
}
else
{
Serial.print("writing Angle: ");
Serial.println(n);
myservo.write(n);
Serial.println();
}
}
}
}
}
}
}