READ sd card then PRINT on LCD then DELETE

Hello community.. im working on a project involving the use of sd card with a txt file save in it. What i want to achieve is I want the arduino to read the first line of the text file inside the sd card then print it on the LCD attach also to arduino. Then clear and delete the first line of the text on a button press.. then loop the process.

Could someone help me in making the code for this? I gave very little knowledge about arduino codes.. but im willing to learn.. Thanks! :slight_smile:

So you want to display a text line by line, with a new line for each button press?

Check the SD card library for examples on reading a line of text. Then the same for the LCD library examples for writing a line of text. Then combine both.

Ok thanks i will do that.. how about to delete the line after it was read and print in the lcd.. i want the line to be deleted when a button is press too.

What exactly do you mean? Delete the line from the SD file, or from the display, or what?

Example of what written inside the text file:

Abc1
Abc2
Abc3

Once abc1 is displayed on lcd because the button is press.. i want the abc1 to be deleted in the text file when the button is press again.. and also be cleared on the lcd display..

Bad news if you want to trim the text file: the entire file must be copied with the line removed.

So i need the program to be saved first.. before deleting the 2nd line?

There exist solutions without deleting lines from the file.

I really dont understand.. sorry

You can read and display the next line of text on a button press.

Will it save the last line that it have read? Incase of power interruption? I dont want it to start all over again.. incase the power is cut.. i need it to read where it left during the power interruption.

You can store the last shown line number in the EEPROM memory. On reset get that number back and skip to this line in the file.

Thanks thats what i need.. by the way im using a 4x20 lcd I2C .. with a sd card module.. and a arduino nano.. what libraries do i need to load for this project?

Ask the IDE library manager.