I’ve got a SD card attached to my Arduino Uno and on that SD card there is a .txt file.
Inside of that .txt file there are numbers written (one number per line).
I now want to compare the value of an integer, with all lines of the .txt file, eg. search for a match.
And I actually have no idea how to approach this. :~
Step 1. Read each line from the file and display it on the serial monitor.
Ok done
Wrong. That is reading and printing each character. You are going to need to store the characters in an array until you encounter the end of record marker, and THEN print the line.
Ok,
but the thing is, that when I start the program, the .txt file will already contain some numbers, but the array will be empty.
How can I access the numbers inside the document and write them into the array? What would be the commands for that?
I know it must be possible somehow, the Arduino reference on SD says: "The File class allows for reading from and writing to individual files on the SD card." http://arduino.cc/de/Reference/SD
Use the read command you've already found. But rather than sending it char by char to serial, store it char by char in your array. Once you find an end of line marker ('\n'). null terminate the array, parse out the values and check whether it's the line you want.