Problems with my webserver

I built a code for Arduino + Ethernet Shield … Relay webserver or Led webserver- works well but in my webpage apears some errors …
My page does not load completely

This is my code


#include <SPI.h>
#include <Ethernet.h>
#include <avr/pgmspace.h>

 byte    mac[] =     { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };   //physical mac address
 byte    ip[] =      { 192, 168, 137, 103 };                     // ip in lan
 byte    gateway[] = { 192, 168, 137, 255 };                       // internet access via router
 byte    subnet[] =  { 255, 255, 255, 0 };                     //subnet mask
 Server  server(80);                // server port
 #define     A_pin 9                
 #define     B_pin 2              
 #define     C_pin 3 
 #define     D_pin 4
 #define     E_pin 5
 #define     F_pin 6
 #define     Y_pin 7
 #define     Z_pin 8
 char    link[]= "";                // link data
 String  readString = String(70);   // string for fetching data from address
 boolean Ledstatus[8];

//var globale, pt afisarea etichetelor(cap de tabel)
char font_gray[] ="<font color=\"black\" size=\"5\">";
char font_green[]="<font color=\"green\" size=\"5\">";

prog_char string0[] PROGMEM = "<font color=\"gray\" size=\"2\"><input type='submit' name='A' value='1'>ON
<input type='submit' name='A' value='0'>OFF</td>";
prog_char string1[] PROGMEM = "<font color=\"gray\" size=\"2\"><input type='submit' name='B' value='1'>ON
<input type='submit' name='B' value='0'>OFF</td>";
prog_char string2[] PROGMEM = "<font color=\"gray\" size=\"2\"><input type='submit' name='C' value='1'>ON
<input type='submit' name='C' value='0'>OFF</td>";
prog_char string3[] PROGMEM = "<font color=\"gray\" size=\"2\"><input type='submit' name='D' value='1'>ON
<input type='submit' name='D' value='0'>OFF</td>";
prog_char string4[] PROGMEM = "<font color=\"gray\" size=\"2\"><input type='submit' name='E' value='1'>ON
<input type='submit' name='E' value='0'>OFF</td>";
prog_char string5[] PROGMEM = "<font color=\"gray\" size=\"2\"><input type='submit' name='F' value='1'>ON
<input type='submit' name='F' value='0'>OFF</td>";
prog_char string6[] PROGMEM = "<font color=\"gray\" size=\"2\"><input type='submit' name='Y' value='1'>ON
<input type='submit' name='Y' value='0'>OFF</td>";
prog_char string7[] PROGMEM = "<font color=\"gray\" size=\"2\"><input type='submit' name='Z' value='1'>ON
<input type='submit' name='Z' value='0'>OFF</td>";

PROGMEM const char *string_table[] = 	   // change "string_table" name to suit
{ string0,
char buffer[140]; //lungimea max a unui string din PROGMEM +1

void setup()
//  Serial.begin(57600); //enable serial datada print
  Ethernet.begin(mac, ip, gateway, subnet); //start Ethernet
  pinMode(A_pin, OUTPUT); //Set pin 4 to output
  pinMode(B_pin, OUTPUT);
  pinMode(C_pin, OUTPUT);
  pinMode(D_pin, OUTPUT);
  pinMode(E_pin, OUTPUT);
  pinMode(F_pin, OUTPUT);
  pinMode(Y_pin, OUTPUT);
  pinMode(Z_pin, OUTPUT);
  Serial.print("Started server");


void loop(){

  Client client = server.available();  // Create a client connection
    if (client) {
      while (client.connected()) {
        if (client.available()) {

          char c =;

        if (readString.length() < 70) { //read char by char HTTP request
          readString.concat(c); } //store characters to string
        Serial.print(c); //output chars to serial port for debugging

        if (c == '\n') { //if HTTP request has ended
          int Ae = readString.indexOf("A=");
          int Be = readString.indexOf("B=");
          int Ce = readString.indexOf("C=");
          int De = readString.indexOf("D=");
          int Ee = readString.indexOf("E=");
          int Fe = readString.indexOf("F=");
          int Ye = readString.indexOf("Y=");
          int Ze = readString.indexOf("Z=");
          //lets check if LED should be lighted
          if (readString.substring(Ae,(Ae+3)) == "A=1") { //led has to be turned ON
              digitalWrite(A_pin, HIGH); // set the LED on
              //Serial.println("A_pin paa");
              Ledstatus[0] = true;
          if (readString.substring(Ae,(Ae+3))== "A=0") {  //led has to be turned OFF
            digitalWrite(A_pin, LOW); // set the LED OFF
            //Serial.println("A_pin av");
            Ledstatus[0] = false;
          if (readString.substring(Be,(Be+3)) == "B=1") {
              digitalWrite(B_pin, HIGH);
              Ledstatus[1] = true;
          if (readString.substring(Be,(Be+3)) == "B=0") {
            digitalWrite(B_pin, LOW); 
            Ledstatus[1] = false;
          if (readString.substring(Ce,(Ce+3)) == "C=0") {
            digitalWrite(C_pin, LOW);
          if (readString.substring(Ce,(Ce+3)) == "C=1") {
            digitalWrite(C_pin, HIGH);
          if (readString.substring(De,(De+3)) == "D=0") {
            digitalWrite(D_pin, LOW);
          if (readString.substring(De,(De+3)) == "D=1") {
            digitalWrite(D_pin, HIGH);
          if (readString.substring(Ee,(Ee+3)) == "E=0") {
            digitalWrite(E_pin, LOW);
          if (readString.substring(Ee,(Ee+3)) == "E=1") {
            digitalWrite(E_pin, HIGH);
          if (readString.substring(Fe,(Fe+3)) == "F=0") {
            digitalWrite(F_pin, LOW);
          if (readString.substring(Fe,(Fe+3)) == "F=1") {
            digitalWrite(F_pin, HIGH);
          if (readString.substring(Ye,(Ye+3)) == "Y=0") {
            digitalWrite(Y_pin, LOW);
          if (readString.substring(Ye,(Ye+3)) == "Y=1") {
            digitalWrite(Y_pin, HIGH);
           if (readString.substring(Ze,(Ze+3)) == "Z=0") {
            digitalWrite(Z_pin, LOW);
          if (readString.substring(Ze,(Ze+3)) == "Z=1") {
            digitalWrite(Z_pin, HIGH);
client.println("HTTP/1.1 200 OK"); // now output HTML data starting with standart header
client.println("Content-Type: text/html");
client.print  ("<body style=background-color:white>"); //set background to white

          // HTML Code
          client.println("<font color=\"blue\"><h2>WEB SERVER PRO</font></h2>");//send first heading
          client.println("<form><table border=2><tr>");
          for(int i=0; i<8; i++){
              if(Ledstatus[i]) client.println(font_green);
                    else       client.println(font_gray);
              strcpy_P(buffer, (char*)pgm_read_word(&(string_table[i])));
              if(i==3) client.println("</tr><tr>"); //new row

client.stop();//stopping client
//Serial.println("Stopper klient");

//clearing string for next read


Please help me to understand why this errors apears :frowning:

Can you paste the html that gets outputted?

Alternatively you may want to take a look at Webduino by Ben Combee and Ran Talbott.

Resolved ! :slight_smile:

client.stop();//stopping client

“delay” was the problem pffffff