我一直非常想在我的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