Reading strings from SD card

I am working on a project that I need to read 84 characters from an SD card, I then display the text on an OLED screen (4 lines of 21 characters) after a delay the screen clears and displays the time for a set period. This process repeats with a second set of 84 characters being read off the SD card then displayed. This whole process repeats until there is no more character available to read off the SD card then the whole process repeats.
I have temporally overcome this by putting the characters in an array using this method
char *screentext[ ] = { "some text 21 chrs line 2 text is here line 3 text is here line 4 text is here ", "screen 2 text line 1 line 2 text is here line 3 text is here line 4 text is here "};

This may be crude but works but I am limited to only 12 screens of three lines of 21 characters. If I make this array any larger the RTC is no longer seen and gives errors. I have tried to read the SD card with each screen of text being a separate file. I can open the file, read the file but am unable to print the contents of the file to the screen. The screen is an I2C Oled and I write to it with
where 'n' is the number of the text in the array, ie screen number.

Hope you can understand what I am trying to do, thanks

Does the file on the SD card respect the line layout with a fixed number of characters or do you have line endings with a carriage return/ line feed that needs to be respected and 84 is just the max you can read?

The SD library has examples showing how you can read a line.

Each file has 84 characters so it will print 4 lines of 21 characters to the screen, the text just overflows into the next line.

So you have multiples files of 84 bytes you want to display in sequence
How do you know which one is first and which one is next?

Post the code.
Which display library are you using?
what type Arduino?
How much memory (program memory and dynamic memory) does the compiler show is being used by the code?

This sounds like a problem with insufficient dynamic memory (RAM).

You likely do not need to read all 84 characters from the SD card then print to the display, printing characters as they are read would eliminate the need for the large array.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.