2
SD card basic file example
4
This example shows how to create and destroy an SD card file
6
* SD card attached to SPI bus as follows:
17
This example code is in the public domain.
27
Serial.print("Initializing SD card...");
28
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
29
// Note that even if it's not used as the CS pin, the hardware SS pin
30
// (10 on most Arduino boards, 53 on the Mega) must be left as an output
31
// or the SD library functions will not work.
35
Serial.println("initialization failed!");
38
Serial.println("initialization done.");
42
printDirectory(root, 0);
44
Serial.println("done!");
49
// nothing happens after setup finishes.
52
void printDirectory(File dir, int numTabs) {
55
File entry = dir.openNextFile();
58
//Serial.println("**nomorefiles**");
61
for (uint8_t i=0; i<numTabs; i++) {
64
Serial.print(entry.name());
65
if (entry.isDirectory()) {
67
printDirectory(entry, numTabs+1);
69
// files have sizes, directories do not
71
Serial.println(entry.size(), DEC);