I have been tinkering around with the code I found in this thread: (RESOLVED) - SD-CARD find a string on text file - Programming Questions - Arduino Forum
and I seem to be getting hung up where it sends the test.txt through the serial moniter. I put in the changes the poster said he used, and changed a few things at the top to allow my setup to work (using a special SD library to allow for SPI on any pin, and assigning those pins). If anyone could please explain to me what is wrong I'd much appreciate it.
#include <SPI.h>
#include <SD.h>
File myFile;
char buf[10];
void setup()
{
Serial.begin(9600);
while (!Serial) {};
Serial.print("Initializing SD Card...");
if (!SD.begin(10, 11, 12, 13)) {
Serial.println("initialization failed");
return;
}
Serial.println("initialization done.");
// re-open the file for reading:
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("test.txt:");
// read from the file until there's nothing else in it:
myFile.read(buf,10);
if(strncmp(buf, "18438846", 8) == 0)
{
Serial.println("Match!");
}
// close the file:
myFile.close();
}
else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
}
void loop()
{
// nothing happens after setup
}