Ethernet shield W5100 non funziona, non pinga.


ciao, ho un problema con la mia ethernet shield w5100 compatibile.
infatti non funziona, quando tento di connettermi il mio browser mi da il seguente errore:
code: [select]
la pagina web non è disponibile
err_connection_timed_out


il codice che ho usato è questo:
code: [select]
#include <spi.h>
#include <ethernet.h>
#include <sd.h>
 
#define maxlength 25
 
byte mac[] = { 0x90, 0xa2, 0xda, 0x00, 0x5a, 0x82 };
byte ip[] = { 192, 168, 1, 89 };
file htmlfile;
ethernetserver server(80);
 
void setup()
{
  serial.begin(9600);
  ethernet.begin(mac, ip);
  server.begin();
  if (!sd.begin(4)) {
    serial.println("scheda sd non inserita correttamente, mi spengo...");
    return;
  }
  pinmode(8, output);
  serial.print("server avviato su: ");
  serial.println(ethernet.localip());
}
 
void loop()
{
  char* file_to_load = "home.htm";
  string instring = string(maxlength);
 
  ethernetclient client = server.available();
  if (client) {
    boolean currentlineisblank = true;
    while (client.connected()) {
      string richiesta;
      if (client.available()) {
        char c = client.read();
        richiesta.concat(c);
        serial.println(richiesta);
        if (instring.length() < maxlength) {
          instring += c;
        }
        if (richiesta.indexof("?led=on") > 0)
        {
          digitalwrite(8, high);
        }
        if (richiesta.indexof("?led=off") > 0)
        {
          digitalwrite(8, low);
        }
       
        if (c == '\n' && currentlineisblank) {
          if (instring.indexof(".htm") > -1) {
            string new_file_load;
            int rootindex = instring.indexof("/");
            new_file_load = instring.substring((rootindex+1), (rootindex+13));
 
            int endindex = new_file_load.indexof(" ");
            if (endindex > -1) {
              new_file_load = new_file_load.substring(0, endindex);
            }
            if (new_file_load != "")  {
              new_file_load.tochararray(file_to_load,12);
            }
          }
 
          client.println("http/1.1 200 ok");
          client.println("content-type: text/html");
          client.println();
 
          read_file("home.htm", client);
 
          break;
        }
        if (c == '\n') {
          currentlineisblank = true;
        }
        else if (c != '\r') {
          currentlineisblank = false;
        }
      }
    }
    delay(1);
    client.stop();
  }
}
 
void read_file( char* page_html, ethernetclient client )
{
  htmlfile = sd.open( page_html );
  if (htmlfile) {
    while (htmlfile.available()) {
        client.write(htmlfile.read());
    }
    // close file:
    htmlfile.close();
  }
}


quando tento di collegarmi led rx e tx dello shield lampeggiano, quindi il segnale ci dovrebbe essere.

prova cambiare mac... metti questo 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed


Arduino Forum > International > Italiano > Generale (Moderator: leo72) > Ethernet shield W5100 non funziona, non pinga.


arduino

Comments