Thank you for the reply.
What i need from the bellow is :
char *datahold;
http://127.0.0.1:90/?cmd=133 -> here i want the datahold = 133
http://127.0.0.1:90/?cmd=1 -> here i want the datahold = 1
http://127.0.0.1:90/?cmd=1335 -> here i want the datahold = 1335
http://127.0.0.1:90/?cmd=A1 -> here i want the datahold = A1
What i have make so far is:
#include <Ethernet.h>
byte mac[] = { (byte)0xDE, (byte) 0xAD, (byte) 0xBE, (byte) 0xEF, (byte)0xFE, (byte) 0xED };
byte ip[] = { 10, 0, 0, (byte) 177 };
Server server(90);
void setup(){
Ethernet.begin(mac, ip);
server.begin();
Serial.begin(9600);
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);
}
void loop(){
String readString="";
Client client = server.available();
if ( client ) {
boolean current_line_is_blank = true;
while (client.connected()) {
if ( client.available() ) {
char c = (char)client.read();
//read char by char HTTP request
if (readString.length() < 100) {
readString += c;
//Serial.print(c);
}
if (c == '\n' && current_line_is_blank) {
//Serial.println(readString);
///////////////////////////////
/////////////////////
if(readString.indexOf("123") > 0)
{
digitalWrite(4, HIGH);
}
if(readString.indexOf("133") > 0)
{
digitalWrite(4, LOW);
}
//clearing string for next read
readString = "";
//////////////////////////////
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.print("
Test Web Server
");
client.print("");
client.print("");
// output the value of each analog input pin
for (int i = 0; i < 6; i++) {
client.print("
");
}
// give the web browser time to receive the data
client.print("");
////////////////////////////////
client.print("
");
client.print("\r\n");
client.print("Enter value (0..255):\r\n");
client.print(" ");
client.print("\r\n");
client.print("");
client.print("
");
///////////////////////////////
break;
}
if (c == '\n') {
// we're starting a new line
current_line_is_blank = true;
} else if (c != '\r') {
// we've gotten a character on the current line
current_line_is_blank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
client.stop();
}
}
If i type 123 then the led turn on, if i will type 133 then the led it is turn off so far so good, but there i compare numbers that i know, me i would like put a random number e.g. 10 and this it will hold the pin 4 for 10Sec on, if i will type 60 then it will hold the pin 4 on for 1 minute.
I don't know how to read the correct length of number, can some one please help me ?
Thank you in advance.
Analog Pin |
Value |
");
client.print(i);
client.print(" |
");
client.print(analogRead(i));
client.println(" |