我一直非常想在我的Arduino uno上运行以太网> DHCPAddressPrinter示例,但是没有效果,每次运行它都会返回错误不能分配MAC地址给Arduino uno以太网盾
无法使用DHCP
我已经尝试了各种各样的事情,那是禁用防火墙,重置板/屏蔽配置的以太网,在启动它给了我一个IP,但是这是唯一的一次,我关掉了路由器,当我打开它以后,我就无法将MAC和IP分配给以太网场。
有谁知道如何解决这个问题?
这里是草图即时试图运行
/*
DHCP-based IP printer
This sketch uses the DHCP extensions to the Ethernet library
to get an IP address via DHCP and print the address obtained.
using an Arduino Wiznet Ethernet shield.
Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
created 12 April 2011
modified 9 Apr 2012
by Tom Igoe
*/
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = {
0xDE, 0xAD, 0xBD, 0xEF, 0xFE, 0xED
};
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
// this check is only needed on the Leonardo:
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
for(;;)
;
}
// print your local IP address:
Serial.print("My IP address: ");
for (byte thisByte = 0; thisByte < 4; thisByte++) {
// print the value of each byte of the IP address:
Serial.print(Ethernet.localIP()[thisByte], DEC);
Serial.print(".");
}
Serial.println();
}
void loop() {
}
我想这码早些时候它显示'0.0.0.0'的IP地址,我也通过启用和禁用DHCP服务器 – dakait
试过你尝试使用不同的MAC地址? –
是的,我把它拿到了IP一次,但是当我用相同的MAC再次拔掉它,它pluffed它没有获得IP从那时起,可能是我的盾牌被打破 – dakait