ethernet shield and lcd

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
treebykooba
 
Posts: 26
Joined: Wed Jun 16, 2010 7:52 am

ethernet shield and lcd

Post by treebykooba »

Hello,
I'm having a very strange problem using my ethernet shield, an lcd and a potentiometer. Any help would be soooo appreciated!!!
I want to be able to use the ethernet shield and at the same time use the potentiometer to change text on the lcd screen (sending html redirects when certain .htm files are accessed on the sdcard). I swear that I had this working no problem for awhile but when I went back into the program to make some changes (and later removing the changes) it's no longer working. The lcd screen only now refreshes with new text when a file is accessed on the sdcard. Why would that be? i am using the code for a webserver i found in the forums here...i will paste it below. Right now I'm just trying to get this very simple code to work in the "if (client.available())" statement so that I can do the html redirects with client.println. (right now none of this redirect stuff is in the code...just trying to get the text to work first)
Here is the simple code that isn't working in the webserver (but works on it's own):

Code: Select all

    
int pot = analogRead(0);
    
 if ((pot > 0)&&(pot < 400)) {
   lcd.clear();
   lcd.print("FIRST CHAMBER");
    
 }     

  if ((pot > 401)&&(pot < 800)) {
    lcd.clear();
    lcd.print("SECOND CHAMBER");
  }
  
   if ((pot > 801)&&(pot < 1024)) {
     lcd.clear();
     lcd.print("THIRD CHAMBER");
   }
             
and here is the webserver code i found in the forums. You can see below where I used to have the if statements...i've tried placing them all over to no avail:

Code: Select all

#include <SPI.h>

    /*
    * Web Server
    *
    * A simple web server that shows the value of the analog input pins.
    */

    #include <SdFat.h>
    #include <SdFatUtil.h>
    #include <Ethernet.h>
#include <LiquidCrystal.h>
    byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
    byte ip[] = { 192, 168, 1, 177 };
    char rootFileName[] = "index.htm";
    Server server(80);
LiquidCrystal lcd(7, 6, 5, 8, 3, 2);
    /************ SDCARD STUFF ************/
    Sd2Card card;
    SdVolume volume;
    SdFile root;
    SdFile file;

    // store error strings in flash to save RAM
    #define error(s) error_P(PSTR(s))

    void error_P(const char* str) {
      PgmPrint("error: ");
      SerialPrintln_P(str);
      if (card.errorCode()) {
        PgmPrint("SD error: ");
        Serial.print(card.errorCode(), HEX);
        Serial.print(',');
        Serial.println(card.errorData(), HEX);
      }
      while(1);
    }

    void setup() {
      Serial.begin(9600);
 lcd.begin(16, 2);
 lcd.print("booting up...");
      PgmPrint("Free RAM: ");
      Serial.println(FreeRam()); 
     
      // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
      // breadboards.  use SPI_FULL_SPEED for better performance.
      pinMode(10, OUTPUT);                       // set the SS pin as an output (necessary!)
      digitalWrite(10, HIGH);                    // but turn off the W5100 chip!

      if (!card.init(SPI_HALF_SPEED, 4)) error("card.init failed!");
     
      // initialize a FAT volume
      if (!volume.init(&card)) error("vol.init failed!");

      PgmPrint("Volume is FAT");
      Serial.println(volume.fatType(),DEC);
      Serial.println();
     
      if (!root.openRoot(&volume)) error("openRoot failed");

      // list file in root with date and size
      PgmPrintln("Files found in root:");
      root.ls(LS_DATE | LS_SIZE);
      Serial.println();
     
      // Recursive list of all directories
      PgmPrintln("Files found in all dirs:");
      root.ls(LS_R);
     
      Serial.println();
      PgmPrintln("Done");
     
      // Debugging complete, we start the server!
      Ethernet.begin(mac, ip);
      server.begin();
    }

    // How big our line buffer should be. 100 is plenty!
    #define BUFSIZ 100

    void loop()
    {
      char clientline[BUFSIZ];
      char *filename;
      int index = 0;
      int image = 0;
 
      Client client = server.available();
      
      if (client) {                                
        // an http request ends with a blank line
        boolean current_line_is_blank = true;
       
        // reset the input buffer
        index = 0;
       
        while (client.connected()) {
          if (client.available()) {
            char c = client.read();
           
            // If it isn't a new line, add the character to the buffer
            if (c != '\n' && c != '\r') {
              clientline[index] = c;
              index++;
              // are we too big for the buffer? start tossing out data
              if (index >= BUFSIZ)
                index = BUFSIZ -1;
             
              // continue to read more data!
              continue;
            }
           
            // got a \n or \r new line, which means the string is done
            clientline[index] = 0;
            filename = 0;
           
            // Print it out for debugging
            Serial.println(clientline);
           
            // Look for substring such as a request to get the root file
            if (strstr(clientline, "GET / ") != 0) {
              filename = rootFileName;
            }
            if (strstr(clientline, "GET /") != 0) {
              // this time no space after the /, so a sub-file
             
              if (!filename) filename = clientline + 5; // look after the "GET /" (5 chars)
              // a little trick, look for the " HTTP/1.1" string and
              // turn the first character of the substring into a 0 to clear it out.
              (strstr(clientline, " HTTP"))[0] = 0;
             
              // print the file we want
              Serial.println(filename);

              if (! file.open(&root, filename, O_READ)) {
                client.println("HTTP/1.1 404 Not Found");
                client.println("Content-Type: text/html");
                client.println();
                client.println("<h2>File Not Found!</h2>");
                break;
              }
                                               
              Serial.println("Opened!");
             
              client.println("HTTP/1.1 200 OK");
              if (strstr(filename, ".htm") != 0)
                 client.println("Content-Type: text/html");
              else if (strstr(filename, ".jpg") != 0)
                 client.println("Content-Type: image/jpeg");
             else if (strstr(filename, ".gif") != 0)
                 client.println("Content-Type: image/gif");
             else
                 client.println("Content-Type: text");

              client.println();
                  
                  
 ///////////////i used to have the simple potentiometer/lcd code here and it worked for
///////////////the longest time...now new text only appears if a file is accessed
   
                  
                   
              int16_t c;
              while ((c = file.read()) >= 0) {
                  // uncomment the serial to debug (slow!)
                  //Serial.print((char)c);
                  client.print((char)c);
              }
              file.close();
            } else {
              // everything else is a 404
              client.println("HTTP/1.1 404 Not Found");
              client.println("Content-Type: text/html");
              client.println();
              client.println("<h2>File Not Found!</h2>");
            }
            break;
          }
        }
        // give the web browser time to receive the data
        delay(1);
        
        client.stop();
      }
      
        
      
    }

Thanks so much for any help!!!

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: ethernet shield and lcd

Post by adafruit_support_bill »

It looks like your LCD code was within the scope of this conditional:

Code: Select all

if (strstr(clientline, "GET /") != 0)
It would only execute if that was true.

User avatar
treebykooba
 
Posts: 26
Joined: Wed Jun 16, 2010 7:52 am

Re: ethernet shield and lcd

Post by treebykooba »

Hi,
Thanks so much for your help. However, it seems that no matter where I put my if conditionals the same behavior applies...the lcd only refreshes when a file is opened. If I put them before that line you quoted or after... If i put the if conditionals out of the if (client) conditional then it's very odd...the text is very dim. Any other ideas?
Thanks!

User avatar
treebykooba
 
Posts: 26
Joined: Wed Jun 16, 2010 7:52 am

Re: ethernet shield and lcd

Post by treebykooba »

also i turned the entire webserver program into a function and placed it before my conditionals. that seems to work but the text on the lcd is very faded. any ideas? here is part of the code (minus the webserver function)

Code: Select all

  void loop () {

    int pot = analogRead(0);
    webserver();
    if ((pot > 0)&&(pot < 400)) {
       lcd.clear();
       lcd.print("FIRST CHAMBER");

    }     

      if ((pot > 401)&&(pot < 800)) {
        lcd.clear();
        lcd.print("SECOND CHAMBER");

      }
     
       if ((pot > 801)&&(pot < 1024)) {
         lcd.clear();
         lcd.print("THIRD CHAMBER");

       }

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: ethernet shield and lcd

Post by adafruit_support_bill »

The text is probably looking faded because it is updating too fast. Add a conditional to test if the value has changed substantially before actually updating the display.

User avatar
treebykooba
 
Posts: 26
Joined: Wed Jun 16, 2010 7:52 am

Re: ethernet shield and lcd

Post by treebykooba »

Hi thank you sooo much for your replies! Putting a delay on the LCD text works fine for now...but I'll write a conditional to make it work better.
Now the problem is, of course, I can't access any of those variables in the webserver(); function. I need to do a client.println(); in my if conditionals in order to have the html redirects...it seems like I have to have the if conditionals somewhere in the webserver program. Maybe I am just thinking about all this wrong. Do you have any other ideas?
Thanks so much for any help

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: ethernet shield and lcd

Post by adafruit_support_bill »

I'm not sure I understand the question. Which variables are you referring to? I don't see any 'webserver()' function in the code you posted either.

User avatar
treebykooba
 
Posts: 26
Joined: Wed Jun 16, 2010 7:52 am

Re: ethernet shield and lcd

Post by treebykooba »

hi thanks again for your help...i thought i got it but i'm still in the same problem.

the webserver() function is just all that webserver code that i pasted up top..i just didn't want to repaste all of it. nothing's changed. any code that i put in the webserver code gets stuck. I have variables that I want to change depending on where the potentiometer is...those variables don't change in the webserver code I posted in the first post.

any ideas?

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: ethernet shield and lcd

Post by adafruit_support_bill »

What variables do you want to change?
Declare them in the scope of the loop() function and change them when you do all the 'pot' logic.
They will be accessible anywhere inside the loop function.

User avatar
treebykooba
 
Posts: 26
Joined: Wed Jun 16, 2010 7:52 am

Re: ethernet shield and lcd

Post by treebykooba »

would it matter if i declared them globally or in the loop()? i had some boolean variables that i declared right away...i put in my 'pot' conditionals and said, for example, if the 'pot' is between 0-400, boolean1=true....then down in the webserver code i said if the boolean1=true, do these html redirects.
when i did that, the code froze and none of the htm files would load into my browser. this is a quick idea of what that looked like: (i'm not in my studio to test out putting the booleans in the loop) any ideas why this code isn't working?
thanks sooo much for any help

Code: Select all

       
  

    #include <SPI.h>

        /*
        * Web Server
        *
        * A simple web server that shows the value of the analog input pins.
        */

        #include <SdFat.h>
        #include <SdFatUtil.h>
        #include <Ethernet.h>
    #include <LiquidCrystal.h>
        byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
        byte ip[] = { 192, 168, 1, 177 };
        char rootFileName[] = "index.htm";
        Server server(80);
    LiquidCrystal lcd(7, 6, 5, 8, 3, 2);
        /************ SDCARD STUFF ************/
        Sd2Card card;
        SdVolume volume;
        SdFile root;
        SdFile file;
boolean first;
boolean second;
boolean third;
        // store error strings in flash to save RAM
        #define error(s) error_P(PSTR(s))

        void error_P(const char* str) {
          PgmPrint("error: ");
          SerialPrintln_P(str);
          if (card.errorCode()) {
            PgmPrint("SD error: ");
            Serial.print(card.errorCode(), HEX);
            Serial.print(',');
            Serial.println(card.errorData(), HEX);
          }
          while(1);
        }

        void setup() {
          Serial.begin(9600);
    lcd.begin(16, 2);
    lcd.print("booting up...");
          PgmPrint("Free RAM: ");
          Serial.println(FreeRam());
         
          // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
          // breadboards.  use SPI_FULL_SPEED for better performance.
          pinMode(10, OUTPUT);                       // set the SS pin as an output (necessary!)
          digitalWrite(10, HIGH);                    // but turn off the W5100 chip!

          if (!card.init(SPI_HALF_SPEED, 4)) error("card.init failed!");
         
          // initialize a FAT volume
          if (!volume.init(&card)) error("vol.init failed!");

          PgmPrint("Volume is FAT");
          Serial.println(volume.fatType(),DEC);
          Serial.println();
         
          if (!root.openRoot(&volume)) error("openRoot failed");

          // list file in root with date and size
          PgmPrintln("Files found in root:");
          root.ls(LS_DATE | LS_SIZE);
          Serial.println();
         
          // Recursive list of all directories
          PgmPrintln("Files found in all dirs:");
          root.ls(LS_R);
         
          Serial.println();
          PgmPrintln("Done");
         
          // Debugging complete, we start the server!
          Ethernet.begin(mac, ip);
          server.begin();
        }

        // How big our line buffer should be. 100 is plenty!
        #define BUFSIZ 100

        void loop()
        {


  int pot = analogRead(0);
       
    if ((pot > 0)&&(pot < 400)) {
       lcd.clear();
       lcd.print("FIRST CHAMBER");
       first=true;
second=false;
third=false;
       
    }     

      if ((pot > 401)&&(pot < 800)) {
        lcd.clear();
        lcd.print("SECOND CHAMBER");
       second=true;
first=false;
third=false;
      }
     
       if ((pot > 801)&&(pot < 1024)) {
         lcd.clear();
         lcd.print("THIRD CHAMBER");
third=true;
first=false;
second=false;
       }
          char clientline[BUFSIZ];
          char *filename;
          int index = 0;
          int image = 0;

          Client client = server.available();
         
          if (client) {                               
            // an http request ends with a blank line
            boolean current_line_is_blank = true;
           
            // reset the input buffer
            index = 0;
           
            while (client.connected()) {
              if (client.available()) {
                char c = client.read();
               
                // If it isn't a new line, add the character to the buffer
                if (c != '\n' && c != '\r') {
                  clientline[index] = c;
                  index++;
                  // are we too big for the buffer? start tossing out data
                  if (index >= BUFSIZ)
                    index = BUFSIZ -1;
                 
                  // continue to read more data!
                  continue;
                }
               
                // got a \n or \r new line, which means the string is done
                clientline[index] = 0;
                filename = 0;
               
                // Print it out for debugging
                Serial.println(clientline);
               
                // Look for substring such as a request to get the root file
                if (strstr(clientline, "GET / ") != 0) {
                  filename = rootFileName;
                }
                if (strstr(clientline, "GET /") != 0) {
                  // this time no space after the /, so a sub-file
                 
                  if (!filename) filename = clientline + 5; // look after the "GET /" (5 chars)
                  // a little trick, look for the " HTTP/1.1" string and
                  // turn the first character of the substring into a 0 to clear it out.
                  (strstr(clientline, " HTTP"))[0] = 0;
                 
                  // print the file we want
                  Serial.println(filename);

                  if (! file.open(&root, filename, O_READ)) {
                    client.println("HTTP/1.1 404 Not Found");
                    client.println("Content-Type: text/html");
                    client.println();
                    client.println("<h2>File Not Found!</h2>");
                    break;
                  }
                                                   
                  Serial.println("Opened!");
                 
                  client.println("HTTP/1.1 200 OK");
                  if (strstr(filename, ".htm") != 0)
                     client.println("Content-Type: text/html");
                  else if (strstr(filename, ".jpg") != 0)
                     client.println("Content-Type: image/jpeg");
                 else if (strstr(filename, ".gif") != 0)
                     client.println("Content-Type: image/gif");
                 else
                     client.println("Content-Type: text");

                  client.println();
                     
/////////////////////////the boolean conditionals...THIS DOESN'T WORK/////////                     
  if ((strstr(filename, "one.htm") != 0)&&(first) {
client.write("<head>");
                    client.write("<meta http-equiv=REFRESH content=0;url=http://192.168.1.177/newpage.htm>");
                    client.write("</head>");
}
         if ((strstr(filename, "one.htm") != 0)&&(second) {
                    client.write("<head>");
                    client.write("<meta http-equiv=REFRESH content=0;url=http://192.168.1.177/newpage.htm>");
                    client.write("</head>");
                 }      
   if ((strstr(filename, "one.htm") != 0)&&(third) {
                    client.write("<head>");
                    client.write("<meta http-equiv=REFRESH content=0;url=http://192.168.1.177/newpage.htm>");
                    client.write("</head>");
                 }   
                  int16_t c;
                  while ((c = file.read()) >= 0) {
                      // uncomment the serial to debug (slow!)
                      //Serial.print((char)c);
                      client.print((char)c);
                  }
                  file.close();
                } else {
                  // everything else is a 404
                  client.println("HTTP/1.1 404 Not Found");
                  client.println("Content-Type: text/html");
                  client.println();
                  client.println("<h2>File Not Found!</h2>");
                }
                break;
              }
            }
            // give the web browser time to receive the data
            delay(1);
           
            client.stop();
          }
         
           
         
        }

                 

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: ethernet shield and lcd

Post by adafruit_support_bill »

the code froze and none of the htm files would load into my browser
Does the pot/lcd part still work?
I don't see anything obvious that would cause it to hang. Why don't you add some Serial.println() statements at various places in your loop so that you can see what parts are actually executing in the Serial Monitor.

User avatar
treebykooba
 
Posts: 26
Joined: Wed Jun 16, 2010 7:52 am

Re: ethernet shield and lcd

Post by treebykooba »

the lcd hangs as well on the "booting up..." text.
the weird thing is...is at one point i replaced the booleans with just a regular int variable. so if pot is between 0 and 400 var=0, if it's between 401-800, var=1 etc. that made everything work. but then the redirects always went to the last conditional in the html redirects part. i did do a lot of Serial.println's....when i did that...the var would come up right, say as two if the pot was set to two...but then the redirect would still go to the third conditional...this is all so weird. the weirdest thing is that i swear this program worked fine before i re-uploaded it to the arduino...frustrating!
thanks again for your help

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: ethernet shield and lcd

Post by adafruit_support_bill »

Can you go back to the last version that worked (when you used the int)? We can start from there and make one change at a time.

User avatar
treebykooba
 
Posts: 26
Joined: Wed Jun 16, 2010 7:52 am

Re: ethernet shield and lcd

Post by treebykooba »

Ok here it is with the int instead of the booleans. Everything works except the redirects only go to the last one (i.e. only newpage3.html gets loaded) no matter where the pot is:

Code: Select all


    #include <SPI.h>

        /*
        * Web Server
        *
        * A simple web server that shows the value of the analog input pins.
        */

        #include <SdFat.h>
        #include <SdFatUtil.h>
        #include <Ethernet.h>
    #include <LiquidCrystal.h>
        byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
        byte ip[] = { 192, 168, 1, 177 };
        char rootFileName[] = "index.htm";
        Server server(80);
    LiquidCrystal lcd(7, 6, 5, 8, 3, 2);
        /************ SDCARD STUFF ************/
        Sd2Card card;
        SdVolume volume;
        SdFile root;
        SdFile file;


int var;


        // store error strings in flash to save RAM
        #define error(s) error_P(PSTR(s))

        void error_P(const char* str) {
          PgmPrint("error: ");
          SerialPrintln_P(str);
          if (card.errorCode()) {
            PgmPrint("SD error: ");
            Serial.print(card.errorCode(), HEX);
            Serial.print(',');
            Serial.println(card.errorData(), HEX);
          }
          while(1);
        }

        void setup() {
          Serial.begin(9600);
    lcd.begin(16, 2);
    lcd.print("booting up...");
          PgmPrint("Free RAM: ");
          Serial.println(FreeRam());
         
          // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
          // breadboards.  use SPI_FULL_SPEED for better performance.
          pinMode(10, OUTPUT);                       // set the SS pin as an output (necessary!)
          digitalWrite(10, HIGH);                    // but turn off the W5100 chip!

          if (!card.init(SPI_HALF_SPEED, 4)) error("card.init failed!");
         
          // initialize a FAT volume
          if (!volume.init(&card)) error("vol.init failed!");

          PgmPrint("Volume is FAT");
          Serial.println(volume.fatType(),DEC);
          Serial.println();
         
          if (!root.openRoot(&volume)) error("openRoot failed");

          // list file in root with date and size
          PgmPrintln("Files found in root:");
          root.ls(LS_DATE | LS_SIZE);
          Serial.println();
         
          // Recursive list of all directories
          PgmPrintln("Files found in all dirs:");
          root.ls(LS_R);
         
          Serial.println();
          PgmPrintln("Done");
         
          // Debugging complete, we start the server!
          Ethernet.begin(mac, ip);
          server.begin();
        }

        // How big our line buffer should be. 100 is plenty!
        #define BUFSIZ 100

        void loop()
        {


  int pot = analogRead(0);
       
    if ((pot > 0)&&(pot < 400)) {
       lcd.clear();
       lcd.print("FIRST CHAMBER");
     var=0;
       
    }     

      if ((pot > 401)&&(pot < 800)) {
        lcd.clear();
        lcd.print("SECOND CHAMBER");
       var=1;
      }
     
       if ((pot > 801)&&(pot < 1024)) {
         lcd.clear();
         lcd.print("THIRD CHAMBER");
var=2;
       }
          char clientline[BUFSIZ];
          char *filename;
          int index = 0;
          int image = 0;

          Client client = server.available();
         
          if (client) {                               
            // an http request ends with a blank line
            boolean current_line_is_blank = true;
           
            // reset the input buffer
            index = 0;
           
            while (client.connected()) {
              if (client.available()) {
                char c = client.read();
               
                // If it isn't a new line, add the character to the buffer
                if (c != '\n' && c != '\r') {
                  clientline[index] = c;
                  index++;
                  // are we too big for the buffer? start tossing out data
                  if (index >= BUFSIZ)
                    index = BUFSIZ -1;
                 
                  // continue to read more data!
                  continue;
                }
               
                // got a \n or \r new line, which means the string is done
                clientline[index] = 0;
                filename = 0;
               
                // Print it out for debugging
                Serial.println(clientline);
               
                // Look for substring such as a request to get the root file
                if (strstr(clientline, "GET / ") != 0) {
                  filename = rootFileName;
                }
                if (strstr(clientline, "GET /") != 0) {
                  // this time no space after the /, so a sub-file
                 
                  if (!filename) filename = clientline + 5; // look after the "GET /" (5 chars)
                  // a little trick, look for the " HTTP/1.1" string and
                  // turn the first character of the substring into a 0 to clear it out.
                  (strstr(clientline, " HTTP"))[0] = 0;
                 
                  // print the file we want
                  Serial.println(filename);

                  if (! file.open(&root, filename, O_READ)) {
                    client.println("HTTP/1.1 404 Not Found");
                    client.println("Content-Type: text/html");
                    client.println();
                    client.println("<h2>File Not Found!</h2>");
                    break;
                  }
                                                   
                  Serial.println("Opened!");
                 
                  client.println("HTTP/1.1 200 OK");
                  if (strstr(filename, ".htm") != 0)
                     client.println("Content-Type: text/html");
                  else if (strstr(filename, ".jpg") != 0)
                     client.println("Content-Type: image/jpeg");
                 else if (strstr(filename, ".gif") != 0)
                     client.println("Content-Type: image/gif");
                 else
                     client.println("Content-Type: text");

                  client.println();
                     
/////////////////////////int conditionals...THIS DOESN'T WORK/////////                     
  if ((strstr(filename, "one.htm") != 0)&&(var=0)) {
client.write("<head>");
                    client.write("<meta http-equiv=REFRESH content=0;url=http://192.168.1.177/newpage1.htm>");
                    client.write("</head>");
}
         if ((strstr(filename, "two.htm") != 0)&&(var=1)) {
                    client.write("<head>");
                    client.write("<meta http-equiv=REFRESH content=0;url=http://192.168.1.177/newpage2.htm>");
                    client.write("</head>");
                 }     
   if ((strstr(filename, "three.htm") != 0)&&(var=2)) {
                    client.write("<head>");
                    client.write("<meta http-equiv=REFRESH content=0;url=http://192.168.1.177/newpage3.htm>");
                    client.write("</head>");
                 }   
                  int16_t c;
                  while ((c = file.read()) >= 0) {
                      // uncomment the serial to debug (slow!)
                      //Serial.print((char)c);
                      client.print((char)c);
                  }
                  file.close();
                } else {
                  // everything else is a 404
                  client.println("HTTP/1.1 404 Not Found");
                  client.println("Content-Type: text/html");
                  client.println();
                  client.println("<h2>File Not Found!</h2>");
                }
                break;
              }
            }
            // give the web browser time to receive the data
            delay(1);
           
            client.stop();
          }
         
           
         
        }

                 

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: ethernet shield and lcd

Post by adafruit_support_bill »

It is the syntax of your "if" statement. A very common error in C/C++ programming is to use '=' when you mean '==':

Code: Select all

 if ((strstr(filename, "one.htm") != 0)&&(var=0)) {
should be:

Code: Select all

 if ((strstr(filename, "one.htm") != 0)&&(var==0)) {
The same change is needed for all 3 if's

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”