When you connect your arduino directly to the PC using the ethernet cable, neither of them have any information about the network.
Most ethernet devices attach to switches, routers, and gateways, and one or more of these devices host network services such as DHCP, DNS, or provide a way to obtain those services.
Without DHCP, for instance, neither your PC nor the Arduino know what IP adress to use, what their netmask is, and whether there's a gateway to other IP addresses.
You have a few options:
- Follow the Automatic Private IP Addressing specification, which windows computers default to when no DHCP server is present or available. Set the IP address of the Arduino to 169.254.x.y where x and y are randomly chosen numbers between 0 and 255, and set th netmask to 255.255.0.0. The windows computer should have done the same if no static IP address was set - use
ipconfig
on the windows command prompt to find its IP address. Your computer and arduino should be able to talk to each other.
- Set up a router. It doesn't need to connect to the internet, it just needs to connect to both the PC and the Arduino. It'll implement a DHCP server and make sure, at minimum, that the two devices can talk to each other and the router.
- Set static IP addresses on both devices. Set up the PC with something like 192.168.42.1 with a netmask of 255.255.0.0 and the Arduino with 192.168.42.2 and the same netmask. Now they should be able to talk to each other.
- Connect both to an existing network. The network should already have a router with DHCP on it, so it'll take care of everything, and as a bonus you may be able to get internet access as well, which could help with testing since you can use the ethernet shield to communicate with google and other known working services, rather than trying to set up a server on the PC.