Show Posts
Pages: [1] 2 3 ... 41
1  Using Arduino / Programming Questions / Webserver failure to communicate on: Today at 01:14:37 am
Dear all
i have code as below. This thing tried on below program.
1) Individually both functions are working fine
2) When i put all together web browser doesn't show any data.

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

const int SENSOR_PIN = A0;
const int SAMPLE_COUNT = 10;
const unsigned long SAMPLE_RATE = 1000UL; // every two seconds
int local_day=12;
int local_month=4;
int local_year=2014;
int local_h=12;
int local_m=12;
int local_s=12;
int LED = 3;          // led is connected to digital pin 3
int PIR = 2;          // PIR sensor is connected to digital pin 2
int LDR = 1;          // LDR sensor is connected to analog in 5
int PIRstate = 0;     // variable for PIR sensor status
float photocell = 0;  // variable for photocell (LDR) analog value
char c = 0;           // received data
char command[2] = "\0";  // command


// array to store the samples
float sample[SAMPLE_COUNT];
byte sampleIndex = 0;
float sampleAverage(void);
static int Wind_Exceed_count;
int Stow_flag=0;
float Wind_Speed;
float Wind_Kmph;

byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = {
  192, 168,1, 120 };   

EthernetServer server(80);


float sampleAverage(void)
{
  float accumulator = 0;
  for (int i = 0; i < SAMPLE_COUNT; i++)
  {
    accumulator += sample[i];
  }
  return accumulator / SAMPLE_COUNT;
}

void Wind_calc()
{
  static unsigned long lastSampleTime = 0;
  unsigned long currentTime = millis();
  // check if time for new reading
  if (currentTime - lastSampleTime >= SAMPLE_RATE)
  {
    lastSampleTime = currentTime;
    int sensorValue = analogRead(SENSOR_PIN);
    float voltage = sensorValue * (5.0 / 1023.0);
    sample[sampleIndex] = voltage;
    sampleIndex++;
    if (sampleIndex == SAMPLE_COUNT)
    {
      sampleIndex = 0;
    }
    float average = sampleAverage();
    Wind_Speed = (6 * average);
    Wind_Kmph = 3.6 * Wind_Speed;

  }
}

void setup()
{
  pinMode(8,OUTPUT);
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
 
}

void loop()
{
  Wind_calc();
  Ethernet_Control();
 
}


void Ethernet_Control()
{
  EthernetClient client = server.available();
  // detect if current is the first line
  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();

          // auto reload webpage every 5 second
          client.println("<META HTTP-EQUIV=REFRESH CONTENT=5 URL=>");

          // webpage title
          client.println("<center><p><h1>NORDIC INDIA SOLAR WEB APPPLICATION V1.0</h1></p><center><hr><br />");
          client.print("<p><h2>DATE: = <font color=indigo>");
          client.print(local_day);
          client.print("/");
          client.print(local_month);
          client.print("/");
          client.print(local_year);
          client.println("</font></h2></p>");
          client.print("<p><h2>TIME: = <font color=indigo>");
          client.print(local_h);
          client.print("/");
          client.print(local_m);
          client.print("/");
          client.print(local_s);
          client.println("</font></h2></p>");
         
          client.print(Wind_Speed);
           client.println("</font></h2></p>");
           client.print("<p><h2>WIND_SPEED KMPH: = <font color=indigo>"); 
           client.print(Wind_Kmph);
           client.println("</font></h2></p>");



          // read digital pin 13 for the state of PIR sensor
          PIRstate = digitalRead(8);
          if (PIRstate == HIGH) { // PIR sensor detected movement
            client.println("<p><h2><font color=red>Motion Detected!</font></h2></p>");
          }
          else { // No movement is detected
            client.println("<p><h2><font color=green>No Movement</font></h2></p>");
          } 

          // button functions
          client.println("<form  method=get name=form>");
          client.println("<button name=b value=1 type=submit style=height:80px;width:150px>LED On</button>");
          client.println("<button name=b value=2 type=submit style=height:80px;width:150px>LED Off</button>");
          client.println("</form><br />");

          // webpage footer
          client.println("<hr><center><a href=http://www.robothead2toe.com.my>Robot.Head to Toe</a><br />");
          client.println("<p>P.S.: This page will automatically refresh every 5 seconds.</p></center>");

          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 == '=') {
          for (int i = 0; i < 1; i++) {
            c = client.read();
            command[i] = c;
          }
          // LED control
          if (!strcmp(command, "1")) {
            digitalWrite(LED, HIGH);
          }
          else if (!strcmp(command, "2")) {
            digitalWrite(LED, LOW);
          }
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    client.stop();
  }
}


2  Using Arduino / Programming Questions / Altering value on webserver. on: April 18, 2014, 07:19:57 am
Dear all.
I am looking for simple example Code where i can edit value on webserver . I found examples for blinking led. reading analog value. But i didnt find any example program Where i can assign value to variable and get changed when put it into update. If any one has implimented code requested to share example code,
3  Using Arduino / Networking, Protocols, and Devices / Re: SD card Intialise error on: April 18, 2014, 06:45:33 am
Code:
The w5100 ethernet controller slave select is D10.
The SD card slave select is D4.

Unless you did some pin bending and a jumper, you can't change those.

Did you reformat the SD card as I recommended?
Can  you share relvant link  to format and How can i use it

4  Using Arduino / Networking, Protocols, and Devices / Re: SD card Intialise error on: April 18, 2014, 06:35:38 am
I am just running example code from arduino example. I am getting error sd card intialise failure error.
As you said i changed from 10 to 3 . Error still there

Code:
#include <SD.h>

File myFile;

void setup()
{
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.print("Initializing SD card...");
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output
  // or the SD library functions will not work.
   pinMode(3, OUTPUT);
   
  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
 
  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  myFile = SD.open("test.txt", FILE_WRITE);
 
  // if the file opened okay, write to it:
  if (myFile) {
    Serial.print("Writing to test.txt...");
    myFile.println("testing 1, 2, 3.");
// close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
 
  // re-open the file for reading:
  myFile = SD.open("test.txt");
  if (myFile) {
    Serial.println("test.txt:");
   
    // read from the file until there's nothing else in it:
    while (myFile.available()) {
    Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
  // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}

void loop()
{
// nothing happens after setup
}

5  Using Arduino / Networking, Protocols, and Devices / Re: Editing option In Websever on: April 18, 2014, 06:27:53 am
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.


Code:
#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("<br />");
          client.println("<br />");
          client.print("LOCAL DATE :");
          client.print(dd);
          client.print("/");
          client.print(mm);
          client.print("/");
          client.print(yy);
          client.println("<br />");   
          client.print("LOCAL TIME :");
          client.print(h);
          client.print("/");
          client.print(m);
          client.print("/");
          client.print(s);
          client.println("<br />");
          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();
}

6  Using Arduino / Networking, Protocols, and Devices / Re: SD card Intialise error on: April 18, 2014, 06:23:25 am
I have use this code . Where i can read data from SD card properly. It also memory being used by each component. I dont know how to enable Slave selector pin while Sd card connected. Thats all missing
Code:
/*
  SD card test
   
 This example shows how use the utility libraries on which the'
 SD library is based in order to get info about your SD card.
 Very useful for testing a card when you're not sure whether its working or not.
 
 The circuit:
  * SD card attached to SPI bus as follows:
 ** MOSI - pin 11 on Arduino Uno/Duemilanove/Diecimila
 ** MISO - pin 12 on Arduino Uno/Duemilanove/Diecimila
 ** CLK - pin 13 on Arduino Uno/Duemilanove/Diecimila
 ** CS - depends on your SD card shield or module.
  Pin 4 used here for consistency with other Arduino examples

 
 created  28 Mar 2011
 by Limor Fried
 modified 9 Apr 2012
 by Tom Igoe
 */
 // include the SD library:
#include <SD.h>

// set up variables using the SD utility library functions:
Sd2Card card;
SdVolume volume;
SdFile root;

// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
const int chipSelect = 4;   

void setup()
{
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.print("\nInitializing SD card...");
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output
  // or the SD library functions will not work.
  pinMode(10, OUTPUT);     // change this to 53 on a mega


  // we'll use the initialization code from the utility libraries
  // since we're just testing if the card is working!
  if (!card.init(SPI_HALF_SPEED, chipSelect)) {
    Serial.println("initialization failed. Things to check:");
    Serial.println("* is a card is inserted?");
    Serial.println("* Is your wiring correct?");
    Serial.println("* did you change the chipSelect pin to match your shield or module?");
    return;
  } else {
   Serial.println("Wiring is correct and a card is present.");
  }

  // print the type of card
  Serial.print("\nCard type: ");
  switch(card.type()) {
    case SD_CARD_TYPE_SD1:
      Serial.println("SD1");
      break;
    case SD_CARD_TYPE_SD2:
      Serial.println("SD2");
      break;
    case SD_CARD_TYPE_SDHC:
      Serial.println("SDHC");
      break;
    default:
      Serial.println("Unknown");
  }

  // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
  if (!volume.init(card)) {
    Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
    return;
  }


  // print the type and size of the first FAT-type volume
  uint32_t volumesize;
  Serial.print("\nVolume type is FAT");
  Serial.println(volume.fatType(), DEC);
  Serial.println();
 
  volumesize = volume.blocksPerCluster();    // clusters are collections of blocks
  volumesize *= volume.clusterCount();       // we'll have a lot of clusters
  volumesize *= 512;                            // SD card blocks are always 512 bytes
  Serial.print("Volume size (bytes): ");
  Serial.println(volumesize);
  Serial.print("Volume size (Kbytes): ");
  volumesize /= 1024;
  Serial.println(volumesize);
  Serial.print("Volume size (Mbytes): ");
  volumesize /= 1024;
  Serial.println(volumesize);

 
  Serial.println("\nFiles found on the card (name, date and size in bytes): ");
  root.openRoot(volume);
 
  // list all files in the card with date and size
  root.ls(LS_R | LS_DATE | LS_SIZE);
}


void loop(void) {
 
}

7  Using Arduino / Programming Questions / Re: Web server program. on: April 18, 2014, 05:48:26 am
In Below Code . i can control the led depend on status. if checked light will blink else light get off. Similar thing i would like to make edit date and time
Code:
#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, 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()
{
    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");
    }
}
8  Using Arduino / Programming Questions / Web server program. on: April 18, 2014, 05:45:56 am
Dear all,

I have code as below . I need your help in below coding. I want to keep edit option For setting date and time ,
If edit date and time is ticked . you can make changes over Web
if edit date and time is unchecked . you see current date and time.

Code:
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1, 178);
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("<br />");   
          client.print("LOCAL TIME :");
          client.print(h);
          client.print("/");
          client.print(m);
          client.print("/");
          client.print(s);
          client.println("<br />");
          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");
  }
}


9  Using Arduino / Networking, Protocols, and Devices / SD card Intialise error on: April 18, 2014, 01:14:11 am
Dear all,

I am running below code on arduino UNO R3 with Ethernet shield. I am getting error saying
ERROR - SD card initialization failed!
Let me know how to resolve this.

Code:
#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>

// size of buffer used to capture HTTP requests
#define REQ_BUF_SZ   20

// 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
File webFile;                    // handle to files on SD card
char HTTP_req[REQ_BUF_SZ] = {0}; // buffered HTTP request stored as null terminated string
char req_index = 0;              // index into HTTP_req buffer

void setup()
{
    // disable Ethernet chip
    pinMode(10, OUTPUT);
    digitalWrite(10, HIGH);
   
    Serial.begin(9600);       // for debugging
   
    // initialize SD card
    Serial.println("Initializing SD card...");
    if (!SD.begin(4)) {
        Serial.println("ERROR - SD card initialization failed!");
        return;    // init failed
    }
    Serial.println("SUCCESS - SD card initialized.");
    // check for index.htm file
    if (!SD.exists("index.htm")) {
        Serial.println("ERROR - Can't find index.htm file!");
        return;  // can't find index file
    }
    Serial.println("SUCCESS - Found index.htm file.");

    Ethernet.begin(mac, ip);  // initialize Ethernet device
    server.begin();           // start to listen for clients
}

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
                // buffer first part of HTTP request in HTTP_req array (string)
                // leave last element in array as 0 to null terminate string (REQ_BUF_SZ - 1)
                if (req_index < (REQ_BUF_SZ - 1)) {
                    HTTP_req[req_index] = c;          // save HTTP request character
                    req_index++;
                }
                Serial.print(c);    // print HTTP request character to serial monitor
                // 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("Connnection: close");
                    client.println();
                    // open requested web page file
                    if (StrContains(HTTP_req, "GET / ")
                                 || StrContains(HTTP_req, "GET /index.htm")) {
                        webFile = SD.open("index.htm");        // open web page file
                    }
                    else if (StrContains(HTTP_req, "GET /page2.htm")) {
                        webFile = SD.open("page2.htm");        // open web page file
                    }
                    // send web page to client
                    if (webFile) {
                        while(webFile.available()) {
                            client.write(webFile.read());
                        }
                        webFile.close();
                    }
                    // reset buffer index and all buffer elements to 0
                    req_index = 0;
                    StrClear(HTTP_req, REQ_BUF_SZ);
                    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)
}

// sets every element of str to 0 (clears array)
void StrClear(char *str, char length)
{
    for (int i = 0; i < length; i++) {
        str[i] = 0;
    }
}

// searches for the string sfind in the string str
// returns 1 if string found
// returns 0 if string not found
char StrContains(char *str, char *sfind)
{
    char found = 0;
    char index = 0;
    char len;

    len = strlen(str);
   
    if (strlen(sfind) > len) {
        return 0;
    }
    while (index < len) {
        if (str[index] == sfind[found]) {
            found++;
            if (strlen(sfind) == found) {
                return 1;
            }
        }
        else {
            found = 0;
        }
        index++;
    }

    return 0;
}
10  Using Arduino / Networking, Protocols, and Devices / Re: Editing option In Websever on: April 18, 2014, 12:30:15 am
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

Code:
#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");
    }
}
11  Using Arduino / Networking, Protocols, and Devices / Re: Editing option In Websever on: April 18, 2014, 12:28:25 am
Not working code That modified. Here webserver get refreshed automatically.
Code:



#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");
    }
}


12  Using Arduino / Networking, Protocols, and Devices / Re: Editing option In Websever on: April 17, 2014, 10:55:29 pm
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 .
13  Using Arduino / Networking, Protocols, and Devices / Re: Editing option In Websever on: April 17, 2014, 05:41:32 am
I could not able to blink led 4 . How can change local date , time on web server.

Code:
#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("<br />"); 
          client.println("<H2>NAVYA TRACKER PROJECT </H2>");
          client.println("<br />"); 
          client.println("<a href=\"/?button1on\"\">Turn On LED</a>");
          client.println("<a href=\"/?button1off\"\">Turn Off LED</a><br />");   
          client.println("<br />");     
          client.println("<br />");

          /*
          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("<br />");   
          client.print("LOCAL TIME :");
          client.print(local_h);
          client.print("/");
          client.print(local_m);
          client.print("/");
          client.print(local_s);
          client.println("<br />");   
          client.print("LATITUDE :");
          client.print(latitude);
          client.print("<br />");   
          client.print("LONGITUDE :");
          client.print(longitude);
          client.println("<br />");   
          client.print("DESIRED ANGLE:");
          client.print(tracker_des_angle);
          client.println("<br />");   
          client.print("ACTUAL ANGLE:");
          client.print(tracker_actual_pos);
          client.println("<br />");   
          client.print("WIND SPEED M/S:");
          client.print(Wind_Speed);
          client.println("<br />");   
          client.print("WIND SPEED KMPH:");
          client.print(Wind_Kmph);
          client.println("<br />");   

          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");


  }
}


14  Using Arduino / Networking, Protocols, and Devices / Editing option In Websever on: April 16, 2014, 11:53:19 pm
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.

Code:
#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("<br />");   
          client.print("LOCAL TIME :");
          client.print(h);
          client.print("/");
          client.print(m);
          client.print("/");
          client.print(s);
          client.println("<br />");
          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");
  }
}

15  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet shield Coding on: April 16, 2014, 10:44:59 pm
@ present i have connected to switch . Where my server mentioned connected to modem.

I have similar set up as shown in image.  But all device connected to switch 5 port.

From Model one LAN connection goto switch port 0
from PC one LAN cable connection goto switch port 1
from Ethernet cable goto switch port 2.
And all under same network.
Question are:
1) how to configure IP address for all, I have made test run for static ip address. connecting directly Ethernet shield and Ethernet port of PC . which is working fine
2) How to control LED in below example. Individually the code working fine.
3)How to keep option to change  date and time here. Which can replicate in web server.



Code:
#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("<br />");  
          client.println("<H2>NAVYA TRACKER PROJECT </H2>");
          client.println("<br />");  
          client.println("<a href=\"/?button1on\"\">Turn On LED</a>");
          client.println("<a href=\"/?button1off\"\">Turn Off LED</a><br />");  
          client.println("<br />");    
          client.println("<br />");

          /*
          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("<br />");  
          client.print("LOCAL TIME :");
          client.print(local_h);
          client.print("/");
          client.print(local_m);
          client.print("/");
          client.print(local_s);
          client.println("<br />");  
          client.print("LATITUDE :");
          client.print(latitude);
          client.print("<br />");  
          client.print("LONGITUDE :");
          client.print(longitude);
          client.println("<br />");  
          client.print("DESIRED ANGLE:");
          client.print(tracker_des_angle);
          client.println("<br />");  
          client.print("ACTUAL ANGLE:");
          client.print(tracker_actual_pos);
          client.println("<br />");  
          client.print("WIND SPEED M/S:");
          client.print(Wind_Speed);
          client.println("<br />");  
          client.print("WIND SPEED KMPH:");
          client.print(Wind_Kmph);
          client.println("<br />");  

          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");


  }
}


Pages: [1] 2 3 ... 41