【发布时间】:2015-07-31 09:18:14
【问题描述】:
我正在尝试在单个项目中使用以太网模块 ENC28J60 (http://www.amazon.com/ENC28J60-Ethernet-Network-Module-STM32/dp/B008B4QIV2) 和 SD 卡模块。我必须从网络中读取数据并将它们写入 micro sd 卡。
我怎样才能做到这一点?我正在通过下面的草图获得以下输出
initialization done.
DONE Ethernet as well with IP: 255.255.255.255
SD 卡已正确初始化,但以太网未正确初始化。 我已分别将针 10,4 用于以太网的 CS、SD 卡。
程序如下
#include "SD.h"
#include "SPI.h"
#include "Ethernet.h"
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,200);
IPAddress gateway(192,168,1,99);
IPAddress mask(255,255,255,0);
//File myFile;
EthernetServer server(80);
void setup()
{
Serial.begin(9600);
if (!SD.begin(4)) {
Serial.println("initialization failed!");
return;
}else {
Serial.println("initialization done.");
}
Ethernet.begin(mac, ip,gateway,gateway,mask);
server.begin();
delay(5000);
Serial.print("DONE Ethernet as well with IP: ");
Serial.println(Ethernet.localIP());
}
void loop(){
//todo
}
【问题讨论】:
标签: arduino ethernet arduino-uno spi