void setup() {
// Open serial communications and wait for port to
open:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect.
Needed for native USB port only
}
// You can use Ethernet.init(pin) to configure the
CS pin
Ethernet.init(PB6);
// start the Ethernet connection:
Serial.println("Initialize Ethernet with DHCP:");
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure
Ethernet using DHCP");
if (Ethernet.hardwareStatus() ==
EthernetNoHardware) {
Serial.println("Ethernet
shield was not found. Sorry, can't run without
hardware. :(");
} else if (Ethernet.linkStatus() ==
LinkOFF) {
Serial.println("Ethernet
cable is not connected.");
}
// no point in carrying on, so do
nothing forevermore:
while (true) {
delay(1);
}
}
if (Ethernet.hardwareStatus() ==
EthernetNoHardware) {
Serial.println("Ethernet shield was not
found.");
}
else if (Ethernet.hardwareStatus() ==
EthernetW5100) {
Serial.println("W5100 Ethernet
controller detected.");
}
else if (Ethernet.hardwareStatus() ==
EthernetW5200) {
Serial.println("W5200 Ethernet
controller detected.");
}
else if (Ethernet.hardwareStatus() ==
EthernetW5500) {
Serial.println("W5500 Ethernet
controller detected.");
}
// print your local IP address:
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
}
|