Go Down

Topic: Char Problem SD Card (Read 424 times) previous topic - next topic

arduino_weather

Hi

I have a problem with my sketch. I read a text from the SD card. Library is SD.h

When I use Serial.print I always get that what I want (say 10 sec) all letters in a new line.
This is what I get:


s
a
y
 
1
0
 
s
e
c


But I want it like this: say 10 sec
And I have to use Serial.print and not Serial.write.
How can I convert it that the format will be correct?

This is the part of my sketch:

 myFile = SD.open("test.txt");
  if (myFile) {
    Serial.println("test.txt:");

    // read from the file until there's nothing else in it:
    while (myFile.available()) {
      Str1 = myFile.read();
      Serial.println(Str1);

 }
    // close the file:
    myFile.close();
     

PaulS

Perhaps you should research the difference between Serial.print() and Serial.println().

Str1 is a stupid name for a character variable. That's like using

Code: [Select]
int float1;
The art of getting good answers lies in asking good questions.

Go Up