Arduino ethershield webserver control 7 segment (3 digit)

Hello!
I need to control 7 segment (3 digit) on webpage by textbox . :~
my condition
if i need to show “999” on 7 segment, I will insert “999” in textbox then i click button to send “999” to 7 segment and show current 7 segment number on webpage also.

now, I can set “999” to show no 7 segment by fix code but i can’t create textbox an send “999” to 7 segment as my condition because i don’t know how to ?
somebody can you help me, please
sorry about my English is not well (so bad) XD

This is some mycode

    #include "etherShield.h"
    static uint8_t mymac[6] = {0x54,0x55,0x58,0x10,0x00,0x24};
    static uint8_t myip[4] = {192,168,1,15};
    static char baseurl[]="http://192.168.1.15/";
    static uint16_t mywwwport =80; // listen port for tcp/www (max range 1-254)

    #define BUFFER_SIZE 500
    static uint8_t buf[BUFFER_SIZE+1];
    #define STR_BUFFER_SIZE 22
    static char strbuf[STR_BUFFER_SIZE+1];
    EtherShield es=EtherShield();
    uint16_t print_webpage(uint8_t *buf, byte on_off);
    uint16_t display_digit(uint16_t ds1);
    int8_t analyse_cmd(char *str);
  //  Use 3 74HC595 shift registers to display 3 numbers 
    int LatchPin = 5;
    int ClockPin = 6;
    int DataPin = 7;
    char m[4];
    byte data;
    byte dataArray[10];

    void setup(){
   
      pinMode(LatchPin, OUTPUT);
      pinMode(ClockPin, OUTPUT);
      pinMode(DataPin, OUTPUT);
      Serial.begin(9600);
          /*initialize enc28j60*/
       es.ES_enc28j60Init(mymac);
       es.ES_enc28j60clkout(2); // change clkout from 6.25MHz to 12.5MHz
       delay(10);
      
            es.ES_enc28j60PhyWrite(PHLCON,0x880);
            delay(500);
            es.ES_enc28j60PhyWrite(PHLCON,0x990);
            delay(500);
            es.ES_enc28j60PhyWrite(PHLCON,0x880);
            delay(500);
            es.ES_enc28j60PhyWrite(PHLCON,0x990);
            delay(500);
      es.ES_enc28j60PhyWrite(PHLCON,0x476);
            delay(100);
           
       es.ES_init_ip_arp_udp_tcp(mymac,myip,80);
            display_digit(000);
    }

    void loop(){
      uint16_t plen, dat_p;
      int8_t cmd;
      byte on_off = 1;
      int8_t Actual=0;

         plen = es.ES_enc28j60PacketReceive(BUFFER_SIZE, buf);
       if(plen!=0){
                       
         if(es.ES_eth_type_is_arp_and_my_ip(buf,plen)){
          es.ES_make_arp_answer_from_request(buf);
          return;
        }

        if(es.ES_eth_type_is_ip_and_my_ip(buf,plen)==0){
          return;
        }
       
        if(buf[IP_PROTO_P]==IP_PROTO_ICMP_V && buf[ICMP_TYPE_P]==ICMP_TYPE_ECHOREQUEST_V){
          es.ES_make_echo_reply_from_request(buf,plen);
          return;
        }
       
        // tcp port www start, compare only the lower byte
        if (buf[IP_PROTO_P]==IP_PROTO_TCP_V&&buf[TCP_DST_PORT_H_P]==0&&buf[TCP_DST_PORT_L_P]==mywwwport){
          if (buf[TCP_FLAGS_P] & TCP_FLAGS_SYN_V){
             es.ES_make_tcp_synack_from_syn(buf); // make_tcp_synack_from_syn does already send the syn,ack
             return;     
          }
          if (buf[TCP_FLAGS_P] & TCP_FLAGS_ACK_V){
            es.ES_init_len_info(buf); // init some data structures
            dat_p=es.ES_get_tcp_data_pointer();
            if (dat_p==0){ // we can possibly have no data, just ack:
              if (buf[TCP_FLAGS_P] & TCP_FLAGS_FIN_V){
                es.ES_make_tcp_ack_from_any(buf);
              }
              return;
            }
            if (strncmp("GET ",(char *)&(buf[dat_p]),4)!=0){
                      // head, post and other methods for possible status codes see:
                // http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
                plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n<h1>200 OK</h1>"));
                goto SENDTCP;
            }
            if (strncmp("/ ",(char *)&(buf[dat_p+4]),2)==0){
                    plen=print_webpage(buf, on_off);
                goto SENDTCP;
             }
            cmd=analyse_cmd((char *)&(buf[dat_p+5]));
            
            if (cmd==2){
                    on_off=1;
                   display_digit(000);
                         }
            else if (cmd==3){
                   on_off=0;
                   display_digit(999);
            }
                      plen=print_webpage(buf, on_off);
                   
                       plen=print_webpage(buf, on_off);
    SENDTCP:  es.ES_make_tcp_ack_from_any(buf); // send ack for http get
               es.ES_make_tcp_ack_with_data(buf,plen); // send data      
          }
        }
      }
            
    }
    ///------------------- 7 segment function-------------------------//
    uint16_t display_digit(uint16_t ds1)
    {
      uint16_t digit[3],i,loop_digit,dis;
   char num_led[17] = {0x3F,0x06,0x5B,0x4F,0x66,
                         0x6D,0x7D,0x07,0x7F,0x6F,
                         0x77,0x7C,0x39,0x5E,0x79,
                         0x50,0x80};

      digit[0] = num_led[ds1%10];
      digit[1] = num_led[(ds1/10)%10];
      digit[2] = num_led[(ds1/100)%10];

      digitalWrite(ClockPin, LOW);
       digitalWrite(LatchPin, HIGH);

      for(loop_digit=0;loop_digit<3;loop_digit++)
        {
         dis = digit[loop_digit];
         for(i=0;i<8;i++)
         {
             if((dis&0x80)==0)
               digitalWrite(DataPin, LOW);
         else
          digitalWrite(DataPin, HIGH);
             dis=dis<<1;
               digitalWrite(ClockPin, HIGH);
               digitalWrite(ClockPin, LOW);
  
           }
        }   
       digitalWrite(LatchPin, LOW);
       digitalWrite(LatchPin, HIGH);

    }

    ///---------------------End of 7 segment function-----------------------//

    uint8_t find_key_val(char *str,char *key)
    {
            uint8_t found=0;
            uint8_t i=0;
            char *kp;
            kp=key;
            while(*str &&  *str!=' ' && found==0){
                    if (*str == *kp){
                            kp++;
                            if (*kp == '\0'){
                                    str++;
                                    kp=key;
                                    if (*str == '='){
                                            found=1;
                                    }
                            }
                    }else{
                            kp=key;
                    }
                    str++;
            }
            if (found==1){
                         while(*str &&  *str!=' ' && *str!='&' && i<STR_BUFFER_SIZE){
                            strbuf[i]=*str;
                            i++;
                            str++;
                    }
                    strbuf[i]='\0';
            }
            return(found);
    }

    int8_t analyse_cmd(char *str)
    {
            int8_t r=-1;
         
            if (find_key_val(str,"cmd")){
                    if (*strbuf < 0x3a && *strbuf > 0x2f){
                            // is a ASCII number, return it
                            r=(*strbuf-0x30);
                    }
            }
            return r;
    }
    ///--------------------- Webpage -----------------------//

    uint16_t print_webpage(uint8_t *buf, byte on_off)
    {
          
           int i=0;
            uint16_t plen;
                
            plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"));
            plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<center><p><h1>Counter Boards Monitoring</h1></p> "));
            plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<hr>
<form METHOD=get action=\""));
            plen=es.ES_fill_tcp_data(buf,plen,baseurl);
            plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("\">"));
            plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<h2> Counter board is </h2> "));
            plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<h1><font color=\"#00FF00\"> "));
             
            if(on_off)
                    plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("Target"));
            else
                    plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("Actual"));
            
            plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("  </font></h1>
 ") );
             if(on_off){
                    plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<input type=hidden name=cmd value=3>"));
                    plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<input type=submit value=\"Set Target\"></form>"));
                          
            }
            else {
                    plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<input type=hidden name=cmd value=2>"));
                    plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<input type=submit value=\"Actual\"></form>"));
            }
                      
            plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("</center><hr> <p>Counter boards monitoring V.1  <a href=\"http://www.XXX.co.th\">http://www.XXX.co.th<a>"));
            return(plen);
    }

A seven segment display can display ONE digit. Unless that is not exactly what you have. If it isn't, you need to clearly describe what it is you have.

Global variables do not need to be static.

Couldyoumaybeusethespacekey,nowandthen,soyourcodecabberead?

i need variables value of 7 segment between 000-999 as number in textbox to show on 7 segment but i don't know to made! =(

i need variables value of 7 segment, 000-999 show on 7 segment but i don't know to made!

I don't understand this. You need help splitting a number into three digits? You need help making one of those digits appear?

no, now i can set 7 segment by this code

   display_digit(999);

but my problem : i don't know how to set number through textbox on webpage.(control by textbox)

Someboday can you help me, please

your html page must be configured to do http post when send button is clicked.
you then need to handle POST request on the webserver code in Arduino.
Most examples floating around are just cover simplistic GET handler.
It is not that hard to handle POST requests. I’m sure you can find plenty of code examples by doing a search.

Hello again!

I change my code for Arduino v1.0 as you see, it’s work by manual (I must enter number at last url ). example “192.168.1.15/200”
but i need to enter number into texbox.
sombody can you help me!!!

//********************************************************///
void loop()
{
//display_digit(000);
char
params;

if (params = server.serviceRequest())
{

server.print(“

7 Segment Monitoring

”);
server.print(“Target: “);
server.print(”<input type=submit name=submit value=SET 7SEG>
“);
//server.print(”<a href=’> <input type=submit name=getit1 value=SET 7SEG>”);

server.print(“7 segment status is :”);
uint16_t a=atoi(params);
//int16_t a=1100
server.print(a);
display_digit(a);

server.respond();
}