SD card, LCD and 2 button

Hi to all Masters,

I need help. this is for my project at may school. just a simple read and delete text on the SD card text file.

the scenario is this. ARDUINO, IIC I2c LCD , 2 buttons and SD card.

the SD card has a text file. text123.text and the content are:

line 1: Ranil Abrasado
line 2: John Rey
line 3: Bode John
line 4: Stephen Beais

///////////////////////////

the 2 buttons are: 1 for read and 1 for delete
///////////////////////////

  1. when i press button 1, arduino will read the SD card text file and display the first line OR last line only to the IIC I2c LCD and then when i press the second button it will delete the text line that is being displayed in the LCD.

Masters and Boss, I really need help.

Thank you in advance

We need to see Your code and maybe the wiring diagram.

Sir here is my sample fritzing. :confused:

Making those things do something is not the most difficult project I have seen. However, You need to get knowledge about coding, discouvering I2C LCD and button reading.
There are suitable kits for novice people giving exercise in how things like this works.
Electronic projects like this are not like kitchening, throwing all the stuff in a bowl, shake it and all is ready.

I apologize Sir's for the my obsession manner looking for help. I'am just a new bee, starting to code in arduino and just basic knowledge in electronics. I try to follow tutorials on how to use SD card , display i2c Lcd and buttons but i really need guidance on how to accomplish this.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
#include <SPI.h>
#include <SD.h>

File myFile;

const int buttonPin1 = 2;
const int buttonPin2 = 3;

int buttonState = 0;

void setup() {

pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
lcd.begin(16,2);
lcd.backlight();

myFile = SD.open("test.txt", FILE_WRITE);

}

void loop()
{

lcd.setCursor(0,0); //we start writing from the first row first column
lcd.print(" Press 1 to desplay"); //16 characters poer line
delay(1000);//Delay used to give a dinamic effect
lcd.setCursor(0,1);
lcd.print("Press 2 to delete");
delay(1000);

buttonState = digitalRead(buttonPin1);

if (buttonState == HIGH) {
lcd.print("Initializing SD card...");
myFile = SD.open("test.txt");
if (myFile) {
// how can i display the first line only?
lcd.print("test.txt:");

while (myFile.available()) {
lcd.write(myFile.read());
}
myFile.close();
} else {
lcd.print("error opening test.txt");
}
}

buttonState = digitalRead(buttonPin2);

if (buttonState == HIGH) {
if (myFile) {

//how can i delect the first line of the text.
lcd.print("Initializing SD card...");
delay(1000);
lcd.print("Writing to test.txt...");
myFile.print(" ");
myFile.close();
lcd.print("Deleted");
} else {
lcd.print("error opening test.txt");
}

}
}

SD card text file. test.text

line1: Ranil Abrasado
line2: Bode John
line3: Stephen Biaes

when i press button 1= desplay line1 text from the SD card to the i2c LCD.
and then if i press the button2 = delete the line1 from sdcard text file

Thank You Sir

i just combine my code from the arduino application examples Sir. my problem is that. i cant display to the LCD the text file from the SD card first line.

what is the best way of displaying text line from SD card? is it the top line text or the bottom?

i dont know how to contract the running code cause i just merge the sample codes that i get from the library.

Thanks.

:confused: OK Sir, I will get back to you when I get what you mean and apply it. and when i have it and still there is a little confusions i will post questions.

Thank you Sir.