Pages: [1]   Go Down
Author Topic: Arduino UNO client webpage design  (Read 1753 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi all i am facing problem with webpage design with arduino uno and Ethernet shield. i am trying to make a web page with a 00 to 9 key pad and buttons for 8 switches to set their timing i have also button for ajust and apply. Nw the problem is that when i make more then 10 buttons  i am unable to ping the server and the web doesnt open ether. i have tried alot but in vain.
 client.println("<button name=b value='A' type=submit style=height:80px;width:200px><p><h2><font color=yellowgreen>ADJUST</font></h2></p></button>");
          client.println("<button name=b value='B' type=submit style=height:80px;width:200px><p><h2><font color=yellowgreen>APPLY</font></h2></p></button>");
 this is the script for adjust and apply button.
please help me on this topic or suggest a better way to do resolve this issue
       
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

here is the complete code even serial port does not display any thing
#include <SPI.h>
#include <Ethernet.h>

// ethernet configuration
byte mac[] = { 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF };
byte ip[] = { 192, 168, 1, 111 }; // P1 --> { 10, 1, 1, 5 };
EthernetServer server(80);              // port 80 is default for HTTP

// initial
int LED = 3;          // led is connected to digital pin 3
char c = 0;           // received data
int command;  // command
int i=0;
int value=0;

void setup()
{
  Serial.begin(9600);
  Ethernet.begin(mac, ip);
  server.begin();
  pinMode(LED, OUTPUT);
  Serial.println("Serial READY");
  Serial.println("Ethernet READY");
  Serial.println("Server READY");
}


void loop()
{
  val();
  command=value;  
 // LED control
        if(command==1)
         {
           command=-1;
          val();
          command=value;
          if(command>=0)
          {
           for(i=command;i>0;i--)
            {
              digitalWrite(LED, HIGH);
              delay(200);
              digitalWrite(LED, LOW);
              delay(200);
        }  
      }
          command=-1;
   }                    
}
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

and this is the html code
void val(void)
 {
   label:
   EthernetClient client = server.available();
  
  boolean current_line_is_first = true;
   if (client) {
    // an http request ends with a blank line
    boolean current_line_is_blank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if we've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so we can send a reply
        if (c == '\n' && current_line_is_blank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
         client.println("<center><p><h1>QUETTA CITY TRAFFIC LIGHTS</h1></p><center><hr><br />");        
          // button functions
          client.println("<dive align=left><form  method=get name=form>");
          client.println("<button name=b value=1 type=submit style=height:50px;width:80px;background-color:#ADD8E6><h3 style=color:blue>S1</h3></button>");
          client.println("<button name=b value=2 type=submit style=height:50px;width:80px;background-color:#ADD8E6><h3 style=color:blue>S2</h3></button>");
          client.println("<br />");
          client.println("<button name=b value=3 type=submit style=height:50px;width:80px;background-color:#ADD8E6><h3 style=color:blue>S3</h3></button>");
          client.println("<button name=b value=4 type=submit style=height:50px;width:80px;background-color:#ADD8E6><h3 style=color:blue>S4</h3></button>");
          client.println("<br />");
          client.println("<button name=b value=5 type=submit style=height:50px;width:80px;background-color:#ADD8E6><h3 style=color:blue>S5</h3></button>");
          client.println("<button name=b value=6 type=submit style=height:50px;width:80px;background-color:#ADD8E6><h3 style=color:blue>S6</h3></button>");
          client.println("<br />");
          client.println("<button name=b value=7 type=submit style=height:50px;width:80px;background-color:#ADD8E6><h3 style=color:blue>S7</h3></button>");
          client.println("<button name=b value=8 type=submit style=height:50px;width:80px;background-color:#ADD8E6><h3 style=color:blue>S8</h3></button>");
          client.println("</form></div><br />");
          client.println("<dive align=right><form  method=get name=form>");
          client.println("<button name=b value='a' type=submit style=height:50px;width:50px;background-color:#7FFF00><h3 style=color:blue>1</h3></button>");
          client.println("<button name=b value='b' type=submit style=height:50px;width:50px;background-color:#7FFF00><h3 style=color:blue>2</h3></button>");
          client.println("<button name=b value='c' type=submit style=height:50px;width:50px;background-color:#7FFF00><h3 style=color:blue>3</h3></button>");
          client.println("<button name=b value='d' type=submit style=height:50px;width:50px;background-color:#7FFF00><h3 style=color:blue>4</h3></button>");
          client.println("<button name=b value='e' type=submit style=height:50px;width:50px;background-color:#7FFF00><h3 style=color:blue>5</h3></button>");
          client.println("<button name=b value='f' type=submit style=height:50px;width:50px;background-color:#7FFF00><h3 style=color:blue>6</h3></button>");
          client.println("<button name=b value='g' type=submit style=height:50px;width:50px;background-color:#7FFF00><h3 style=color:blue>7</h3></button>");
          client.println("<button name=b value='h' type=submit style=height:50px;width:50px;background-color:#7FFF00><h3 style=color:blue>8</h3></button>");
          client.println("<br />");
          client.println("<button name=b value='i' type=submit style=height:50px;width:50px;background-color:#7FFF00><h3 style=color:blue>9</h3></button>");
          
          client.println("<button name=b value='%' type=submit style=height:50px;width:50px;background-color:#7FFF00><h3 style=color:blue>00</h3></button>");
          client.println("</form></div><br />");
          break;
        }
        if (c == '\n') {
          // we're starting a new line
          current_line_is_first = false;
          current_line_is_blank = true;
        }
        else if (c != '\r') {
          // we've gotten a character on the current line
          current_line_is_blank = false;
        }
        // get the first http request
        if (current_line_is_first && c== '=') {
            c= client.read();
           switch (c)
           {
             case 1:
              {
                value=101;
                c=0;
                break;
              }
             case 2:
              {
                value=102;
                c=0;
                break;
              }
             case 3:
              {
                value=103;
                c=0;
                break;
              }  
             case 4:
              {
                value=104;
                c=0;
                break;
              }  
             case 5:
              {
                value=105;
                c=0;
                break;
              }  
             case 6:
              {
                value=106;
                c=0;
                break;
              }  
             case 7:
              {
                value=107;
                c=0;
                break;
              }  
             case 8:
              {
                value=108;
                c=0;
                break;
              }  
             case '%':
               {
                 value=0;
                 c=0;
                break;
              }  
             case 'a':
               {
                 value=1;
                 c=0;
                break;
              }  
              case 'b':
               {
                 value=2;
                 c=0;
                break;
              }  
             case 'c':
               {
                 value=3;
                 c=0;
                break;
              }  
             case 'd':
               {
                 value=4;
                 c=0;
                break;
              }  
             case 'e':
               {
                 value=5;
                 c=0;
                break;
              }  
             case 'f':
               {
                 value=6;
                 c=0;
                break;
              }  
             case 'g':
               {value=7;
               c=0;
                break;
              }  
              case 'h':
               {
                 value=8;
                 c=0;
                break;
              }  
             case 'i':
               {
                 value=9;
                 c=0;
                break;
              }  
        
            /* default:
              {
                value=-1;
                goto label;
              }*/
           }
          
      }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    client.stop();
  }
 }
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Each literal string used in a client.println() is placed in SRAM. Each of these lines:
Code:
client.println("<button name=b value=1 type=submit style=height:50px;width:80px;background-color:#ADD8E6><h3 style=color:blue>S1</h3></button>");
take around 125 bytes of SRAM.

You have 17 lines like this using over 2100 bytes of SRAM, plus the other client.println() lines, plus any other variables that your sketch and the libraries that you are using require. That has to come out of the 2048 bytes of SRAM that the Uno has. You could try using the F() macro, which keeps literal strings in the Flash memory area.

Code:
client.println(F("<button name=b value=1 type=submit style=height:50px;width:80px;background-color:#ADD8E6><h3 style=color:blue>S1</h3></button>"));
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@dxwood thanx for your assistance that worked fine but my final program will be much longer then this one and space of ROM will be insufficient. so is there any way that i can use SD card for RAM purpose ???
Logged

Orlando, FL
Offline Offline
Newbie
*
Karma: 0
Posts: 32
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I know it's not what you are asking but you can keep your html codes and buttons on your server and you can pass a parameter to arduino to do things..
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@MTD any example for that ??? how to send the values ??? because this code reads the ltr after /?=  value
Logged

Pages: [1]   Go Up
Jump to: