Pages: [1]   Go Down
Author Topic: Problema collegamento con Ethernet Shield R3  (Read 637 times)
0 Members and 1 Guest are viewing this topic.
near Slovenia
Offline Offline
Jr. Member
**
Karma: 1
Posts: 65
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Salve,
ho collegato Arduino Uno R3 e Ethernet Shield R3 insieme,collegato con USB e cavo RJ45 al MacBook e il codice come prova è questo (vedi qui sotto) in altro modo come posso?Io uso Arduino 1.0.1 per programmare,ma alla fine mi dice errore della libreria w5100.cpp e w5100.h.Che cosa devo fare?Grazie.
Code:
#include <SPI.h>
#include <Ethernet.h>


byte mac[] = {  0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
char serverName[] = "www.google.com";

EthernetClient client;

void setup() {
  Serial.begin(9600);
   while (!Serial) {
    ;
  }


 
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    while(true);
  }
  delay(1000);
  Serial.println("connecting...");

 
 
  if (client.connect(serverName, 80)) {
    Serial.println("connected");
    client.println("GET /search?q=arduino HTTP/1.0");
    client.println();
  }
  else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    while(true);
  }
}
Logged

Cagliari, Italy
Offline Offline
Tesla Member
***
Karma: 110
Posts: 6974
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ciao,
su WinXP, IDE 1.0.1 compila perfettamente.

Prova a riscaricare l'IDE e ricopia qui sul forum gli errori che ti da. Cosi ci facciamo un'idea più precisa.
Logged

Code fast. Code easy. Codebender --> http://codebender.cc/?referrer=PaoloP

near Slovenia
Offline Offline
Jr. Member
**
Karma: 1
Posts: 65
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Va bene, scaricherò gli errori che mi dà,grazie PaoloP.
Logged

Italy
Offline Offline
Full Member
***
Karma: 6
Posts: 102
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ho appena provato con macbook, UNO, ETH shield tutto R3 e compila senza problemi
N.
Logged

"The question is not whether intelligent machines can have emotions, but whether machines can be intelligent without any emotions"

near Slovenia
Offline Offline
Jr. Member
**
Karma: 1
Posts: 65
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Gli errori:
Code:
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/utility/w5100.cpp: In member function 'void W5100Class::init()':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/utility/w5100.cpp:28: error: 'delay' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/utility/w5100.cpp:30: error: 'SPI' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/utility/w5100.cpp: In static member function 'static uint8_t W5100Class::write(uint16_t, uint8_t)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/utility/w5100.cpp:133: error: 'SPI' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/utility/w5100.cpp: In static member function 'static uint16_t W5100Class::write(uint16_t, const uint8_t*, uint16_t)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/utility/w5100.cpp:146: error: 'SPI' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/utility/w5100.cpp: In static member function 'static uint8_t W5100Class::read(uint16_t)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/utility/w5100.cpp:159: error: 'SPI' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/utility/w5100.cpp: In static member function 'static uint16_t W5100Class::read(uint16_t, uint8_t*, uint16_t)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/utility/w5100.cpp:172: error: 'SPI' was not declared in this scope
Logged

near Slovenia
Offline Offline
Jr. Member
**
Karma: 1
Posts: 65
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Salve,
ho collegato Arduino Uno R3 e Ethernet Shield R3 insieme,collegato con USB e cavo RJ45 (no cavo cross over-incrociato) al MacBook e il codice come prova è questo (vedi qui sotto).Al Monitor Seriale compare così:
coconnecting…
connection failed

disconnecting.
Che cosa devo fare?Grazie.

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


byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x23, 0x1F };
byte ip[] = {  192,168,2,4 };
byte server[] = { 173, 194, 35, 151 }; // Google
byte subnet[] = { 255, 255, 255, 0 };    //subnet mask of the network
byte gateway[] = { 192, 168, 2, 1 };   //your router's IP address

EthernetClient client;

void resetEthernet() {
  client.stop();
  delay(1000);
  Ethernet.begin(mac, ip, gateway, subnet);
  delay(1000);
}
void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);

  delay(1000);

  Serial.println("connecting...");

  if (client.connect(server, 80)) {
    Serial.println("connected");
    client.println("GET /search?q=arduino HTTP/1.0");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;;)
      ;
  }
}
Logged

Pages: [1]   Go Up
Jump to: