Problem of connecting Ethernet shield

Hello everyone,

I have been trying to connect to a website with my Ethernet shiled for about two weeks. I searched everywhere and tried everything that I can found. This is the example code that I am trying to get worked (It is provided by Arduino);

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

byte mac = { 0xSS, 0xSS, 0xSS, 0xSS, 0xSS, 0xSS };
byte ip = { 139, 0, 0, 0};

EthernetClient client;

void setup()
{
Ethernet.begin(mac, ip);
Serial.begin(9600);

delay(1000);

Serial.println(Ethernet.localIP());
Serial.println(“connecting…”);

if (client.connect(“http://mr_paradox.byethost31.com/”,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(;:wink:
;
}
}

Note that I changed MAC adress and IP address to not share them in here :slight_smile: MAC address is already written on the shield, I guess it cannot create a problem. About IP address, I am trying to connect in an university network, therefore I have some unsureness about finding a valid IP adress since most of them should be occuppied by different computers in the campus. Another point that may cause a problem is Internet sharing. I am connected to Internet via Wifi. When I checked the box that says “allow other network users to connect through this computer’s Internet connection” and tried to connect to Internet with another computer which is connected to “server” computer with ethernet cable, it simply does not work. I cannot connect to Internet with second computer. Moreover, I tried different technique that is"bridge connections". That way I could connect to Internet with second computer. However, both of these methods could not work for arduino, client.connect method always returns false. What should I do?

Thank you if you read that much writing :slight_smile:

Yigit

Change:   Ethernet.begin(mac, ip); To:   Ethernet.begin(mac);

See if the network will assign you an IP address via DHCP.

If you specify an IP address and don't specify the DNS Server Address, Gateway Address, and Subnet Mask then the .begin() is going to use a bunch of defaults. If those defaults are not correct for your network then nothing is going to work.