Editing option In Websever

Here i put my code. Here i am displaying date and time on web server. I would like to know how to create tag for Editing date and time . once edited time being changed in Server.

#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,7, 100);
EthernetServer server(80);
#include "Wire.h"
#define DS1307_ADDRESS 0x68
byte zero = 0x00; //workaround for issue #527
static int dd;
static int mm;
static int yy;
static int s;
static int h;
static int m;
static int wkDay;
int CENTURY=2000;
int RTC_ERROR_FLAG=0;


void getRTCDateTime(){

  Wire.beginTransmission(DS1307_ADDRESS);
  Wire.write(zero);
  Wire.endTransmission();
  Wire.requestFrom(DS1307_ADDRESS, 7);

  if(RTC_ERROR_FLAG==0)
  {
    //Serial.println("RTC IS ACTIVE :\n");
    s = bcdToDec(Wire.read());
    m = bcdToDec(Wire.read());
    h = bcdToDec(Wire.read() & 0b111111); //24 hour time
    wkDay = bcdToDec(Wire.read()); //0-6 -> sunday - Saturday
    dd = bcdToDec(Wire.read());
    mm = bcdToDec(Wire.read());
    yy = CENTURY + bcdToDec(Wire.read());

  }
}


byte decToBcd(byte val){
  // Convert normal decimal numbers to binary coded decimal
  return ( (val/10*16) + (val%10) );
}

byte bcdToDec(byte val)  {
  // Convert binary coded decimal to normal decimal numbers
  return ( (val/16*10) + (val%16) );
}

int getLastTwoDigOfYear(int y){
  return(y%1000); 
}



void rtcWrite(){

  Wire.beginTransmission(DS1307_ADDRESS);
  Wire.write(zero); //stop Oscillator

  Wire.write(decToBcd(s));
  Wire.write(decToBcd(m));
  Wire.write(decToBcd(h));
  Wire.write(decToBcd(wkDay));
  Wire.write(decToBcd(dd));
  Wire.write(decToBcd(mm));
  Wire.write(decToBcd(getLastTwoDigOfYear(yy)));

  Wire.write(zero); //start

  Wire.endTransmission();


}




void setup()
{
  Serial.begin(9600);
  Wire.begin();
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
} 
void loop()
{
  getRTCDateTime();
  Ethernet_webserver();

  delay(1000);
}
void Ethernet_webserver()
{
  EthernetClient client = server.available();
  if (client) 
  {
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connnection: close");
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // add a meta refresh tag, so the browser pulls again every 5 seconds:
          client.println("<meta http-equiv=\"refresh\" content=\"5\">");
          // add sententence here
          client.print("LOCAL DATE :"); 
          client.print(dd);
          client.print("/");
          client.print(mm);
          client.print("/");
          client.print(yy); 
          client.println("
");   
          client.print("LOCAL TIME :"); 
          client.print(h);
          client.print("/");
          client.print(m);
          client.print("/");
          client.print(s); 
          client.println("
");
          client.println("</html>");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } 
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disonnected");
  }
}

I could not able to blink led 4 . How can change local date , time on web server.

#include <SPI.h>
#include <Ethernet.h>
String readString;
int led = 4;
byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,7, 150);
EthernetServer server(80);
int local_day=12;
int local_month=04;
int local_year=2014;
int local_h=12;
int local_m=30;
int local_s=21;
float latitude=15.08;
float longitude=58.05;
float tracker_des_angle=45.0;
float tracker_actual_pos=43.0;
int Wind_Speed=12;
int Wind_Kmph=120;

void setup()
{

  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());



}
void loop()
{
  Ethernet_webserver();
}


void Ethernet_webserver()
{
  EthernetClient client = server.available();
  if (client) 
  {
    boolean currentLineIsBlank = true;
    while (client.connected()) 
    {
      if (client.available())
      {
        char c = client.read();
        if (c == '\n' && currentLineIsBlank)
        {
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connnection: close");
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
          // add a meta refresh tag, so the browser pulls again every 5 seconds:
          client.println("<meta http-equiv=\"refresh\" content=\"5\">");
          client.println("<TITLE>NAVYA TITLE </TITLE>");
          client.println("</HEAD>");
          client.println("<BODY>");
          client.println("<H1>NAVYA TITLE </H1>");
          client.println("<hr />");
          client.println("
");  
          client.println("<H2>NAVYA TRACKER PROJECT </H2>");
          client.println("
");  
          client.println("<a href=\"/?button1on\"\">Turn On LED</a>");
          client.println("<a href=\"/?button1off\"\">Turn Off LED</a>
");   
          client.println("
");     
          client.println("
"); 

          /*
          client.println("<!DOCTYPE HTML>");
           client.println("<html>");*/
          // add a meta refresh tag, so the browser pulls again every 5 seconds:
          //  client.println("<meta http-equiv=\"refresh\" content=\"5\">");
          // add sententence here
          client.print("LOCAL DATE :"); 
          client.print(local_day);
          client.print("/");
          client.print(local_month);
          client.print("/");
          client.print(local_year); 
          client.println("
");   
          client.print("LOCAL TIME :"); 
          client.print(local_h);
          client.print("/");
          client.print(local_m);
          client.print("/");
          client.print(local_s); 
          client.println("
");   
          client.print("LATITUDE :");
          client.print(latitude); 
          client.print("
");   
          client.print("LONGITUDE :");
          client.print(longitude); 
          client.println("
");   
          client.print("DESIRED ANGLE:");
          client.print(tracker_des_angle); 
          client.println("
");   
          client.print("ACTUAL ANGLE:");
          client.print(tracker_actual_pos); 
          client.println("
");   
          client.print("WIND SPEED M/S:");
          client.print(Wind_Speed); 
          client.println("
");   
          client.print("WIND SPEED KMPH:");
          client.print(Wind_Kmph); 
          client.println("
");   

          client.println("</html>");
          //break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
          if (readString.indexOf("?button1on") >0){
            digitalWrite(led, HIGH);
          }
          if (readString.indexOf("?button1off") >0){
            digitalWrite(led, LOW);
          }
          readString="";  
        } 
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();

    Serial.println("client disonnected");


  }
}

I could not able to blink led 4

If you are using the official Ethernet shield with SD card, pin 4 is the slave select pin for the SD card.

i have made changes pin 4 to 7 . Even through it is not blinking. Is there any way to make our own customized web server .

Not working code That modified. Here webserver get refreshed automatically.

#include <SPI.h>
#include <Ethernet.h>
#include "actuator.h"
#include "config.h"
#include "mode.h"
#include"timecalc.h"

#include"pos.h"
#include"spa.h"
#include"glob.h"

#include "rtc.h"
#include "diag.h"
#include "hwconfig.h"
#include "diag.h"
#include <Time.h>
#include <avr/wdt.h>
Timer t;
#include"print.h"
#include"wind.h"


String HTTP_req; 
boolean LED_status = 0; 

byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,7, 178);
EthernetServer server(80);
void flash() {
  static boolean output = HIGH;
  digitalWrite(13, output);
  output = !output;
  
}

void setup()
{
  pinMode(9,OUTPUT);
  Serial.begin(9600);
// setSyncProvider(RTC.get);   // the function to get the time from the RTC
  setupActuator();
  wdt_enable(WDTO_8S);
  MODE=INIT;

  rtcSetup();

 

  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());


}


void loop()
{
    Ethernet_webserver();
  Serial.println("......................");
 delay(1000);
}


void Ethernet_webserver()
{
    EthernetClient client = server.available();  // try to get client

    if (client) {  // got client?
        boolean currentLineIsBlank = true;
        while (client.connected()) {
            if (client.available()) {   // client data available to read
                char c = client.read(); // read 1 byte (character) from client
                HTTP_req += c;  // save the HTTP request 1 char at a time
                // last line of client request is blank and ends with \n
                // respond to client only after last line received
                if (c == '\n' && currentLineIsBlank) {
                    // send a standard http response header
                    client.println("HTTP/1.1 200 OK");
                    client.println("Content-Type: text/html");
                    client.println("Connection: close");
                    client.println();
                    // send web page
                    client.println("<!DOCTYPE html>");
                    client.println("<html>");
                    client.println("<head>");
                    client.println("<title>Arduino LED Control</title>");
                    client.println("</head>");
                    client.println("<body>");
                    client.println("<h1>LED</h1>");
                    client.println("<p>Click to switch LED on and off.</p>");
                    client.println("<form method=\"get\">");
                    ProcessCheckbox(client);
                    client.println("</form>");
                    client.println("</body>");
                    client.println("</html>");
                    Serial.print(HTTP_req);
                    HTTP_req = "";    // finished with request, empty string
                    break;
                }
                // every line of text received from the client ends with \r\n
                if (c == '\n') {
                    // last character on line of received text
                    // starting new line with next character read
                    currentLineIsBlank = true;
                } 
                else if (c != '\r') {
                    // a text character was received from client
                    currentLineIsBlank = false;
                }
            } // end if (client.available())
        } // end while (client.connected())
        delay(1);      // give the web browser time to receive the data
        client.stop(); // close the connection
    } 
}


void ProcessCheckbox(EthernetClient cl)
{
    if (HTTP_req.indexOf("LED2=2") > -1) {  // see if checkbox was clicked
        // the checkbox was clicked, toggle the LED
        if (LED_status) {
            LED_status = 0;
        }
        else {
            LED_status = 1;
        }
    }
    
    if (LED_status) {    // switch LED on
        digitalWrite(9, HIGH);
        // checkbox is checked
        cl.println("<input type=\"checkbox\" name=\"LED2\" value=\"2\" \
        onclick=\"submit();\" checked>LED2");
    }
    else {              // switch LED off
        digitalWrite(9, LOW);
        // checkbox is unchecked
        cl.println("<input type=\"checkbox\" name=\"LED2\" value=\"2\" \
        onclick=\"submit();\">LED2");
    }
}

Below code is working fine. I wanted to combine with other part s like View parameter date and time.

Below code only to blink LED using web server

#include <SPI.h>
#include <Ethernet.h>

// MAC address from Ethernet shield sticker under board
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 7, 178); // IP address, may need to change depending on network
EthernetServer server(80);  // create a server at port 80

String HTTP_req;          // stores the HTTP request
boolean LED_status = 0;   // state of LED, off by default

void setup()
{
    Ethernet.begin(mac, ip);  // initialize Ethernet device
    server.begin();           // start to listen for clients
    Serial.begin(9600);       // for diagnostics
    pinMode(8, OUTPUT);       // LED on pin 2
}

void loop()
{
    EthernetClient client = server.available();  // try to get client

    if (client) {  // got client?
        boolean currentLineIsBlank = true;
        while (client.connected()) {
            if (client.available()) {   // client data available to read
                char c = client.read(); // read 1 byte (character) from client
                HTTP_req += c;  // save the HTTP request 1 char at a time
                // last line of client request is blank and ends with \n
                // respond to client only after last line received
                if (c == '\n' && currentLineIsBlank) {
                    // send a standard http response header
                    client.println("HTTP/1.1 200 OK");
                    client.println("Content-Type: text/html");
                    client.println("Connection: close");
                    client.println();
                    // send web page
                    client.println("<!DOCTYPE html>");
                    client.println("<html>");
                    client.println("<head>");
                    client.println("<title>Arduino LED Control</title>");
                    client.println("</head>");
                    client.println("<body>");
                    client.println("<h1>LED</h1>");
                    client.println("<p>Click to switch LED on and off.</p>");
                    client.println("<form method=\"get\">");
                    ProcessCheckbox(client);
                    client.println("</form>");
                    client.println("</body>");
                    client.println("</html>");
                    Serial.print(HTTP_req);
                    HTTP_req = "";    // finished with request, empty string
                    break;
                }
                // every line of text received from the client ends with \r\n
                if (c == '\n') {
                    // last character on line of received text
                    // starting new line with next character read
                    currentLineIsBlank = true;
                } 
                else if (c != '\r') {
                    // a text character was received from client
                    currentLineIsBlank = false;
                }
            } // end if (client.available())
        } // end while (client.connected())
        delay(1);      // give the web browser time to receive the data
        client.stop(); // close the connection
    } // end if (client)
}

// switch LED and send back HTML for LED checkbox
void ProcessCheckbox(EthernetClient cl)
{
    if (HTTP_req.indexOf("LED2=2") > -1) {  // see if checkbox was clicked
        // the checkbox was clicked, toggle the LED
        if (LED_status) {
            LED_status = 0;
        }
        else {
            LED_status = 1;
        }
    }
    
    if (LED_status) {    // switch LED on
        digitalWrite(8, HIGH);
        // checkbox is checked
        cl.println("<input type=\"checkbox\" name=\"LED2\" value=\"2\" \
        onclick=\"submit();\" checked>LED2");
    }
    else {              // switch LED off
        digitalWrite(8, LOW);
        // checkbox is unchecked
        cl.println("<input type=\"checkbox\" name=\"LED2\" value=\"2\" \
        onclick=\"submit();\">LED2");
    }
}

Do you still have the SD card in the shield’s slot? If so, I do not see in your code where you are disabling the SD card SPI. That could cause problems with the w5100.

I have SD card sheild , but not inserted any SD card. yet.

In below code I can change status of pin that get reflected on webserver,. But i could not able edit my own date and time. Date is atomically set to default value.I wanted to say

IF Edit option is checked
Edit date and time
else
keep updating time

IS SD card need to above requirement.

#include <SPI.h>
#include <Ethernet.h>

#include "Wire.h"
#define DS1307_ADDRESS 0x68
byte zero = 0x00; //workaround for issue #527
static int dd;
static int mm;
static int yy;
static int s;
static int h;
static int m;
static int wkDay;
int CENTURY=2000;
int RTC_ERROR_FLAG=0;


// MAC address from Ethernet shield sticker under board
byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 178); // IP address, may need to change depending on network
EthernetServer server(80);  // create a server at port 80

String HTTP_req;          // stores the HTTP request
boolean LED_status = 0;   // state of LED, off by default

void setup()
{
  Wire.begin();  
  Ethernet.begin(mac, ip);  // initialize Ethernet device
  server.begin();           // start to listen for clients
  Serial.begin(9600);       // for diagnostics
  pinMode(8, OUTPUT);       // LED on pin 2
}

void loop()
{
  //getRTCDateTime();
  EthernetClient client = server.available();  // try to get client

  if (client) {  // got client?
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {   // client data available to read
        char c = client.read(); // read 1 byte (character) from client
        HTTP_req += c;  // save the HTTP request 1 char at a time
        // last line of client request is blank and ends with \n
        // respond to client only after last line received
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println("Connection: close");
          client.println();
          // send web page
          client.println("<!DOCTYPE html>");
          client.println("<html>");
          client.println("<head>");
          client.println("<title>Arduino LED Control</title>");
          client.println("</head>");
          client.println("<body>");
          client.println("<h1>EDIT</h1>");
          client.println("<p>Click to switch LED on and off.</p>");
          client.println("<form method=\"get\">");
          ProcessCheckbox(client);
          client.println("
");
          client.println("
");
          client.print("LOCAL DATE :"); 
          client.print(dd);
          client.print("/");
          client.print(mm);
          client.print("/");
          client.print(yy); 
          client.println("
");   
          client.print("LOCAL TIME :"); 
          client.print(h);
          client.print("/");
          client.print(m);
          client.print("/");
          client.print(s); 
          client.println("
");
          client.println("</html>");
          break;




          client.println("</form>");
          client.println("</body>");
          client.println("</html>");
          Serial.print(HTTP_req);
          HTTP_req = "";    // finished with request, empty string
          break;
        }
        // every line of text received from the client ends with \r\n
        if (c == '\n') {
          // last character on line of received text
          // starting new line with next character read
          currentLineIsBlank = true;
        } 
        else if (c != '\r') {
          // a text character was received from client
          currentLineIsBlank = false;
        }
      } // end if (client.available())
    } // end while (client.connected())
    delay(1);      // give the web browser time to receive the data
    client.stop(); // close the connection
  } // end if (client)
}

// switch LED and send back HTML for LED checkbox
void ProcessCheckbox(EthernetClient cl)
{
  /*  if (HTTP_req.indexOf("LED2=2") > -1) {  // see if checkbox was clicked
        // the checkbox was clicked, toggle the LED
        if (LED_status) {
            LED_status = 0;
        }
        else {
            LED_status = 1;
        }
    }
    
    if (LED_status) {    // switch LED on
        digitalWrite(8, HIGH);
        // checkbox is checked
        cl.println("<input type=\"checkbox\" name=\"LED2\" value=\"2\" \
        onclick=\"submit();\" checked>LED2");
    }
    else {              // switch LED off
        digitalWrite(8, LOW);
        // checkbox is unchecked
        cl.println("<input type=\"checkbox\" name=\"LED2\" value=\"2\" \
        onclick=\"submit();\">LED2");
    }
    
    */
    if (HTTP_req.indexOf("LED2=2") > -1) 
    { 
     if (LED_status) {
            LED_status = 0;
        }
        else {
            LED_status = 1;
        }
    }
    
    if (LED_status) 
    { 
      rtcWrite(s,m,h,2,dd,mm, yy);
      cl.print("IN SET MODE");
      //setDateTime();
       digitalWrite(8, HIGH);
      cl.println("<input type=\"checkbox\" name=\"LED2\" value=\"2\" \
        onclick=\"submit();\" checked>LED2");
      
    }else
    {
     cl.print("read mode");
       digitalWrite(8, LOW);
      getRTCDateTime();
       cl.println("<input type=\"checkbox\" name=\"LED2\" value=\"2\" \
        onclick=\"submit();\">LED2");
    }
    
    
}




































void getRTCDateTime(){

  Wire.beginTransmission(DS1307_ADDRESS);
  Wire.write(zero);
  Wire.endTransmission();
  Wire.requestFrom(DS1307_ADDRESS, 7);

  if(RTC_ERROR_FLAG==0)
  {
    //Serial.println("RTC IS ACTIVE :\n");
    s = bcdToDec(Wire.read());
    m = bcdToDec(Wire.read());
    h = bcdToDec(Wire.read() & 0b111111); //24 hour time
    wkDay = bcdToDec(Wire.read()); //0-6 -> sunday - Saturday
    dd = bcdToDec(Wire.read());
    mm = bcdToDec(Wire.read());
    yy = CENTURY + bcdToDec(Wire.read());

  }
}


byte decToBcd(byte val){
  // Convert normal decimal numbers to binary coded decimal
  return ( (val/10*16) + (val%10) );
}

byte bcdToDec(byte val)  {
  // Convert binary coded decimal to normal decimal numbers
  return ( (val/16*10) + (val%16) );
}

int getLastTwoDigOfYear(int y){
  return(y%1000); 
}


/*
void setDateTime(){

  byte second =      12; //0-59
  byte minute =      12; //0-59
  byte hour =        12; //0-23
  byte weekDay =    2; //1-7
  byte monthDay =    12; //1-31
  byte month =       12; //1-12
  byte year  =       15; //0-99

  Wire.beginTransmission(DS1307_ADDRESS);
  Wire.write(zero); //stop Oscillator

  Wire.write(decToBcd(second));
  Wire.write(decToBcd(minute));
  Wire.write(decToBcd(hour));
  Wire.write(decToBcd(weekDay));
  Wire.write(decToBcd(monthDay));
  Wire.write(decToBcd(month));
  Wire.write(decToBcd(year));

  Wire.write(zero); //start

  Wire.endTransmission();

}*/



void rtcWrite(int sec1,int min1,int hour1, int  wkday1,int dd1,int mm1,int yy1){

  /* Serial.println("In RTC write function");
   Serial.print("date");
   Serial.print(dd1);
   Serial.print("/");
   Serial.print(mm1);
   Serial.print("/");
   Serial.print(yy1); 
   */
  int year1;  
 // rtcSetup();
  Wire.beginTransmission(DS1307_ADDRESS);
  Wire.write(zero); //stop Oscillator

  Wire.write(decToBcd(sec1));
  Wire.write(decToBcd(min1));
  Wire.write(decToBcd(hour1)& 0b111111);
  Wire.write(decToBcd(wkday1));
  Wire.write(decToBcd(dd1));
  Wire.write(decToBcd(mm1));
  //Wire.write(decToBcd(yy1);
  Wire.write(decToBcd(getLastTwoDigOfYear(yy1)));

  //year1= Wire.write(decToBcd(getLastTwoDigOfYear(yy1)));
  //Serial.print("date in rtc write:");
  //Serial.println(year1);
  Wire.write(zero); //start
  Wire.endTransmission();
}