How to read value from browser into arduino


hi,

i have arduino uno + ethernet shield, using these have develop code web server. web page simple 1 numeric input field, 1 submit button , 1 numeric indicator. checked example code of web server , tried biggest hurdle html since don't have knowledge of it.still html commands can make webpage.
here half code
code: [select]
#include<spi.h>                                            // initialize spi server library
#include<ethernet.h>                                      // initialize ethernet server library


byte mac[] = {0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed};        //declare mac address of uno + ethernet shield
byte ip[] = {192,168,0,102};                              //declare ip address of uno + ethernet shield
byte gateway[] = {192,168,0,252};
byte subnet[] = {255,255,255,0};
ethernetserver server (80);                                //declare http port (default 80)

boolean initial = 0;
string resp, value;
int value2;

void setup()
{
  serial.begin(9600);
  ethernet.begin(mac, ip, gateway, gateway, subnet);
  server.begin();
  serial.print("server @ ");
  serial.println(ethernet.localip());
}

void loop()
{
  ethernetclient client = server.available();
  if(client)
  {
    serial.println("new client");
    boolean currentlineisblank = true;
    resp = " ";
    while(client.connected())
    {
      if(client.available())
      {
        char c = client.read();
        serial.write(c);
        resp += c;
       
        if(c == '\n' && currentlineisblank)
        {
          client.println("http/1.1 200 ok");                                    //standard response successful http requests.
          client.println("content-type: text/html");                          //content type html text
          client.println("connection: close");                              //the connection closed after completion of response
          client.println();
          client.println("<!doctype html>");                          //each html document requires document type declaration
          client.println("<html>");                                   //the <html> tag tells browser html document.
          client.println("<h1>enter numeric value</h1>");
          client.println("<p/>");                                     //the <p> tag defines paragraph.
          client.println("<form method = 'get'>");
          client.println("<input type = 'number' id = 'input'>");
          client.println("<input type = 'submit' value = 'submit' onclick = submit()>");
          client.println("<p/>");
          client.println("</form>");
          client.println("</html>"); 
   break;
        }
        if (c == '\n')
        {
          currentlineisblank = true;
        }
        else if (c != '\r')
        {
          currentlineisblank = false;
        }
      }
    }
    delay(1);
    client.stop();
  }   
}

oh! sorry forgot mention requirement. when enter 5 digit value numeric field , click submit button, through browser query want 5 digit value in 1 variable of arduino code. because have perform mathematical calculations on , again display on browser.

if has idea, please help

thank u
ratna


Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > How to read value from browser into arduino


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code