iframe question on ethernet board


hi,
im learning on zoomkats iframe code, made 4 link slowdata if
click on data should refresh every 10 seconds when click on it
it takes refresh time 0 fastdata, can me ?
see code below
greetings , thanks

code: [select]

#include <arduino.h>
#define echo_ingangspin 7 // ingang echo pin
#define trigger_uitgangspin 8 // trigger uitgangspin
int maximumrange = 300;
int minimumrange = 2;

// zoomkat's meta refresh data frame test page 5/25/13
// use http://192.168.1.102:84 in brouser main page
// http://192.168.1.102:84/data static data page
// http://192.168.1.102:84/datastart meta refresh data page
// use w5100 based ethernet shields
// set refresh rate 0 fastest update
// use stop single data updates

#include <spi.h>
#include <ethernet2.h>
long afstand;
long duur;
const int analoginpin0 = a0;
const int analoginpin1 = a1;
const int analoginpin2 = a2;
const int analoginpin3 = a3;
const int analoginpin4 = a4;
const int analoginpin5 = a5;

byte mac[] = { 0x90, 0xa2, 0xda, 0x10, 0xb4, 0x00}; //physical mac address
byte ip[] = { 10, 33, 211, 179}; // arduino ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
ethernetserver server(80); //server port
unsigned long int x=0; //set refresh counter 0
string readstring;

//////////////////////

void setup(){
  pinmode(trigger_uitgangspin, output);
  pinmode(echo_ingangspin, input);
  serial.begin(9600);
    // disable sd spi if memory card in usd slot
  pinmode(4,output);
  digitalwrite(4,high);

  ethernet.begin(mac, ip, gateway, gateway, subnet);
  server.begin();
  serial.println("meta refresh data frame test 5/25/13"); // can keep track of loaded
}
/////////////////////////////////////////////////
void loop(){
  ethernetclient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
         if (readstring.length() < 100) {
          readstring += c;
         }
        //check if http request has ended
        if (c == '\n') {

          //check atring received
          serial.println(readstring);

          //output html data header
          client.println("http/1.1 200 ok");
          client.println("content-type: text/html");
          client.println();

          //generate data page
          if(readstring.indexof("data") >0) {  //checks "data" page
           
            x=x+1; //page upload counter
            client.print("<html><head>");
           
            //meta-refresh page every 1 seconds if "datastart" page
            if(readstring.indexof("datastart") >0) client.print("<meta http-equiv='refresh' content='1'>");
           
            //meta-refresh 0 fast data
            if(readstring.indexof("datafast") >0) client.print("<meta http-equiv='refresh' content='0'>");

            //meta-refresh 10 slowdata
            if(readstring.indexof("slowdata") >0) client.print("<meta http-equiv='refresh' content='10'>");
           
            client.print("<title>zoomkat's meta-refresh test</title></head><body><br>");
            client.print("page refresh number: ");
            client.print(x); //current refresh count
            client.print("<br><br>");
            // nieuw stuk
            // pulse van 10µs die word gestuurd
            digitalwrite(trigger_uitgangspin, high);
            delaymicroseconds(10);
            digitalwrite(trigger_uitgangspin, low);
            duur = pulsein(echo_ingangspin, high);
           
            afstand = duur/58.2;
              //output value of each analog input pin
            if (afstand >= maximumrange || afstand <= minimumrange); 
           
            client.print("afstand: ");
            client.print(afstand); 
           
                       
            client.print("<br>analog input0 is: ");
            client.print(analogread(analoginpin0));

            client.print("<br>analog input1 is: ");
            client.print(analogread(analoginpin1));

            client.print("<br>analog input2 is: ");
            client.print(analogread(analoginpin2));

            client.print("<br>analog input3 is: ");
            client.print(analogread(analoginpin3));

            client.print("<br>analog input4 is: ");
            client.print(analogread(analoginpin4));

            client.print("<br>analog input5 is: ");
            client.print(analogread(analoginpin5));
            client.println("<br></body></html>");
           }
          //generate main page iframe
          else
          {
            client.print("<html><head><title>zoomkat's frame refresh test</title></head>");
            client.print("zoomkat's arduino frame meta refresh test 5/25/13");
            client.print("<br><br>arduino analog input data frame:<br>");
            client.print("&nbsp;&nbsp;<a href='/datastart' target='databox' title=''aa''>meta-refresh</a>");
            client.print("&nbsp;&nbsp;&nbsp;&nbsp;<a href='/data' target='databox' title=''bb''>single-stop</a>");
            client.print("&nbsp;&nbsp;&nbsp;&nbsp;<a href='/datafast' target='databox' title=''cc''>fast-data</a>");
           
           
            client.print("&nbsp;&nbsp;&nbsp;&nbsp;<a href='/datafaster' target='databox' title=''dd''>slow-data</a><br>");
         
            client.print("<iframe src='/data' width='350' height='500' name='databox'>");
            client.print("</iframe><br></html>");
          }
          delay(100);
          //stopping client
          client.stop();
          //clearing string next read
          readstring="";
        }
      }
    }
  }
}



quote
can me ?
have tried printing readstring when discover c equals '\n'? i'm willing bet clue-by-four whacks when do.


Arduino Forum > Using Arduino > Programming Questions > iframe question on ethernet board


arduino

Comments

Popular posts from this blog

DHT11 Time out error using v0.4.1library

Sketch upload fails with Java error (___REMOVE___/bin/avrdude)!

Arduino Uno + KTY81/210 temperature sensor