I am trying to use Ethernet module ENC28J60 (http://www.amazon.com/ENC28J60-Ethernet-Network-Module-STM32/dp/B008B4QIV2) and SD Card module in single project. I have to read data from the network and write them into the micro sd card.
How can I achieve this? I am getting following output from by sketch below
initialization done.
DONE Ethernet as well with IP: 255.255.255.255
SD card is initialized correctly, but Ethernet is not. I have used pin 10,4 for CS of Ethernet, SD card respectively.
Program is as below
#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
}