初始化以太网库并进行网络设置。
在1.0版本,该库支持DHCP服务器。 使用 Ethernet.begin(mac)和正确的网络设置,以太网模块会自动获得一个IP地址。这将显著的增加这个代码的使用范围。
Ethernet.begin(mac); Ethernet.begin(mac, ip); Ethernet.begin(mac, ip, ); Ethernet.begin(mac, ip, 网关, 子网掩码);
无
#include <Ethernet.h> //设置MAC地址: byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //设置模块的IP地址: byte ip[] = { 10, 0, 0, 177 }; void setup() { Ethernet.begin(mac, ip); } void loop() { }