send data from a web server to arduino

Hi!

i haver a virtual server domain and a arduino mega with a ethernet shield.
I managed to configure the arduino to send get data through the web server and save them in a txt file.
Once I have the data on the server I made a website in php that collects data from the txt file and then using javascript and buttons change the variables.

Now I have a problem. How do I send data to the arduino ?
I think it would be using the post method from javascript but this is possible ? As I pick up on arduino ?
I'm stuck now

Thank you very much for your time .

Read your php page in arduino, and compare string.

:fearful: ok its true! I can create a string in php. Write with echo and read with arduino. It is ok?
But the arduino are read all time.
but is there any way to tell the arduino to read at a given time and save processing cycles and keep on arduino read continuously
Thank you

knibal:
:fearful: ok its true! I can create a string in php. Write with echo and read with arduino. It is ok?

yes
You can use json format
http://forum.arduino.cc/index.php?topic=214331.msg1570083#msg1570083

But the arduino are read all time.
but is there any way to tell the arduino to read at a given time and save processing cycles and keep on arduino read continuously
Thank you

I dont know that I true understand, but maybe something like this

long lastMillis = 0;
long loops = 0;

void setup(){
  Serial.begin(9600);
}

void loop(){
  long currentMillis = millis();
  loops++;
  
  /* By doing complex math, reading sensors, using the "delay" function,
  *  etc you will increase the time required to finish the loop,
  *  which will decrease the number of loops per second.
  */

  if(currentMillis - lastMillis > 1000){
    Serial.print("Loops last second:");
    Serial.println(loops);
    
    lastMillis = currentMillis;
    loops = 0;
  }
}

Have a look at this series of tutorials Arduino Ethernet Shield Web Server Tutorial where you'll find the answer to your question and more. Cheers.

Ok thank you very much I will try to make it work well .
:wink: