- 语法
- 参数
- 返回值
EthernetNoHardware
EthernetW5100
EthernetW5200
EthernetW5500
- 例子
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);
void setup() {
//打开串行通信并等待端口打开
Serial.begin(9600);
while (!Serial) {
; // 等待串行端口连接 。仅本地USB端口需要
}
Ethernet.begin(mac, ip);
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.");
}
}
void loop () {}
- 串口打印结果:
1.5 Ethernet.init()
- 描述
- 语法
- 参数
- 返回值
- 例子
#include <SPI.h>1.6 Ethernet.linkStatus()
#include <Ethernet.h>
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);
void setup() {
Ethernet.init(53);// 将引脚53用于以太网CS
Ethernet.begin(mac, ip);
}
void loop () {}
- 描述
- 语法
- 参数
- 返回值
Unknown
LinkON
LinkOFF
- 例子
#include <SPI.h>
#include <Ethernet.h>
void setup() {
//打开串行通信并等待端口打开
Serial.begin(9600);
while (!Serial) {
; // 等待串行端口连接 。仅本地USB端口需要
}
}
void loop () {
if (Ethernet.linkStatus() == Unknown) {
Serial.println("Link status unknown. Link status detection is only available with W5200 and W5500.");
}
else if (Ethernet.linkStatus() == LinkON) {
Serial.println("Link status: On");
}
else if (Ethernet.linkStatus() == LinkOFF) {
Serial.println("Link status: Off");
}
}
- 串口打印结果:
1.7 Ethernet.localIP()
- 描述
- 语法
- 参数
- 返回值
- 例子
#include <SPI.h>
#include <Ethernet.h>
// 在下面输入控制器的MAC地址 。
// 较新的以太网防护罩在防护罩上的标签上印有MAC地址
byte mac[] = {
0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };推荐阅读
- 微信图片已被清理如何恢复 微信己被清理的图片如何恢复
- 新车撞了能恢复原样吗 车被撞还能恢复到原来的样子吗
- 湛江两名男子用弹弓射击、粘网猎捕南迁候鸟!均被警方刑拘
- 如何找回被删除的微信好友 如何恢复已经删除的微信好友
- 微信被删除了怎么加回来 微信怎么测试谁把你删除了
- 手机怎么登录两个微信号 手机号被另一个微信绑定了
- 投诉电话查询12345被威胁 投诉电话查询12345
- 成都被狗咬伤女童转出ICU!院方披露医疗费用
- 高中孩子被孤立怎么开导好 高中孩子被孤立怎么开导
- 十岁小女孩被骗两万元……家长要注意了!
