Hello guys,
Just starting to use SD.h library to access my SD card. I tried many examples and all work just fine.
Finally i tried to use sd library to my program, but program stuck to void setup and nn particular to "SD.begin(4)" command.
As you can see to my program i use serial.println for debugging, and at my screen while program starts i see only "Initializing SD card..."
I use an arduino uno and an ethernet shield.
Any ideas? Thanks in advance!
#include <Time.h>
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <SD.h>
// MAC address from Ethernet shield sticker under board
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 20); // IP address, may need to change depending on network
IPAddress dns1(192,168,1,1);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);
EthernetServer server(80); // create a server at port 80
//NTP Info
IPAddress timeServer(132, 163, 4, 101); // time-a.timefreq.bldrdoc.gov
const int timeZone = 3; // Central European Time
unsigned int localPort = 8888; // local port to listen for UDP packets
EthernetUDP Udp;
String HTTP_req; // stores the HTTP request
boolean LED_status = 0; // state of LED, off by default
boolean RELAY_status = 0; // state of Relay, off by default
boolean RELAY2_status = 0; // state of Relay, off by default
float temp;
int tempPin = 0;
void setup()
{
Ethernet.begin(mac, ip, dns1, gateway, subnet); // initialize Ethernet device
server.begin(); // start to listen for clients
Serial.begin(9600); // for diagnostics
digitalWrite(10, HIGH);
// initialize SD card
Serial.println("Initializing SD card...");
if (!SD.begin(4)) {
Serial.println("ERROR - SD card initialization failed!");
return; // init failed
}
Serial.println("SUCCESS - SD card initialized.");
if (!SD.exists("index.htm")) {
Serial.println("ERROR - Can't find index.htm file!");
return; // can't find index file
}
Serial.println("SUCCESS - Found index.htm file.");
pinMode(2, OUTPUT); // LED on pin 2
pinMode(3, OUTPUT); // LED on pin 2
pinMode(5, OUTPUT); // LED on pin 2
Udp.begin(localPort);
setSyncProvider(getNtpTime);
}
........
......
myprogram.ino (11 KB)