Thanks to zoomkat for the help getting me this far
So far i have an "on" and "off" button that controlls an led on pin 4
and a status showing the led status
Then i have a text box with a submit button, when i enter a value say 554 and press submit i get
http://10.1.1.177/?form=554How do i then assign the value 554 to "int analog"
heres my code
//*******************************
#include <SPI.h>
#include <Ethernet.h>
int analog ;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 10,10,1,145 }; // ip in lan
byte gateway[] = { 123,197,43,36 }; // the IP of the router or acsesspoint
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask (i dont think this is neccesary
Server server(80); // server port (change this if you are having a local webserver else than the arduino)
int ledPin = 4; // LED pin
int sensorPin = A0; // analog in 0 for testing
int sensorValue = 0; // integer for the analog sensor
String readString = String(30); // string for fetching data from address
boolean LEDON = false; // LED status flag
void setup()
{
Serial.begin (9600);
Ethernet.begin(mac, ip, gateway, subnet); //start Ethernet
pinMode(ledPin, OUTPUT); //Set pin 4 to output
analog = 100;
}
void loop(){
Client client = server.available(); // Create a client connection
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (readString.length() < 30) { //read char by char HTTP request
readString += c; } //store characters to string
if (c == '\n') { //if HTTP request has ended
int stringthing = readString.indexOf("="); //here is a key component of where the status is being read by the arduino
Serial.println (readString);
if (stringthing > 1){
if (readString.indexOf ("on")>0) { //led has to be turned ON
digitalWrite(ledPin, HIGH); // set the LED on
LEDON = true;
}
if (readString.indexOf( "off") >0) {
//led has to be turned OFF
digitalWrite(ledPin, LOW); // set the LED OFF
LEDON = false;
}
}
client.println("HTTP/1.1 200 OK"); //output HTML data starting with standart header
client.println("Content-Type: text/html");
client.println();
client.print("<form method=get name=LED>LED .<input type='submit' name='Led' value='on'> <input type='submit' name='Led' value='off'>");
//client.println ("<input type=submit value=buton_name>"); //submit button
client.print("LED status: ");
if (LEDON == true) {
client.println("ON");
}
else {
client.println("OFF");
}
client.print ("</p>");
client.print ("<form name=input action= method= get ><input type= text name= form value= 'analog' /><input type= submit value= Submit /></form>");
client.print ("</p>");
client.print ( analog );
client.println("</body></html>");
readString=""; //clearing string for next read
client.stop(); //stopping client
}}}}}
Any help or direction will be much apreciated, cheers, corey