Basically what this code does is to print all the information inside the "file.txt" that is written on my sd card. My problem is that to some txt files that I generate on my computer this program doesn't work. It seems that it doesn't recognize any of the information in the file that I have created...
Am I missing something in this code? Is it supposed to work fine?
I've tried to change the SD partition to FAT16 but it didn't work as well. Does anyone know why I can read some .txt files with this code and others I can't?
Why don't you attach a file that CAN be read and another that CAN'T be read?
Without seeing what works and what doesn't, there isn't much we could say specifically.
Basically I made the following tests with two files, file1.txt and file2.txt (by changing the name of the file in the line readFile = SD.open("file2.txt"). They both have exactly the same content.
file1.txt:
G28
M106
Serial Monitor Output of file1.txt:
Beginning to print:
X
1
0
8
.
8
9
9
9
readFile return: 1
file2.txt:
G28
M106
Serial Monitor Output of file2.txt:
Beginning to print:
G
2
8
M
1
0
6
readFile return: 1
Different outputs to the same content isn't making any sense to me at all. It seems that when I create new text inside the .txt file on my computer the Arduino doesn't recognize what I wrote.
I have tried to use the notepad++ on windows and the gedit on Ubuntu..
Also, I've traded my SD module connected to the Arduino Mega board. But the output is the same as above for both of my SD modules, so I believe it isn't a problem with it.
PS: If I trade the names of the files file1.txt and file2.txt to file2.txt and file1.txt the one that will print the content correct will be the file1.txt...