#include <SPI.h>
#include <SD.h>
#define chipSelect 5
void setup() {
Serial.begin(9600);
while (!Serial) {
; // wait for Serial Monitor to connect
}
Serial.print("Initializing SD card...");
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
return;
}
Serial.println("card initialized.");
// Open the file for reading
File file = SD.open("/data.txt");
if (file) {
Serial.println("File content:");
// read the file line by line
while (file.available()) {
Serial.write(file.read());
}
file.close();
} else {
Serial.println("Error opening file");
}
}
void loop() {
// nothing to do here
}