read contents of a text file from sd card line by line to 1602 lcd help

Hello, I've just started out with Arduino and programming this week and could do with some help.

I have a Arduino uno with a sd card shield with rtc clock on, and a lcd 1602 shield.

both shields work fine etc.

I'm trying to read a file from the sd card line by line and send it to the lcd so the lcd scrolls the text then clears then displays next line of text.

I have tried many examples and having no luck at all.

I am trying to make a reminder system for my uncle who has alzheimers, I want to (in the end) be able to read from the sd card, match the date with a entry in the text file and display the next words.

for example the text file could have format of

date , Birthday of xxx date , Doctors 2pm

so when the date arrives the Arduino would send the reminder for whats happening that day.

is theres anyone that could give me any pointers as I'm now totally lost :(.

I have done this code but it doesn’t work.

#include <SD.h>
#include <Wire.h>
#include "RTClib.h"
#include <LiquidCrystal.h>
#include <LCDKeypad.h>

#define MINVAL 1
#define MAXVAL 1000
File myFile;
LCDKeypad lcd;
String readFileValue();
String readFileValue(){  
  FILE filePointer;  

int currentChar; 
char initCharArray[100];  
int i = 0;  

}


byte c_up[8] = {
  B00100,
  B01110,
  B10101,
  B00100,
  B00100,
  B00100,
  B00100,
  B00100,
};

byte c_down[8] = {
  B00100,
  B00100,
  B00100,
  B00100,
  B00100,
  B10101,
  B01110,
  B00100,
};

byte c_select[8] = {
  B00000,
  B01110,
  B11111,
  B11111,
  B11111,
  B11111,
  B01110,
  B00000,
};

uint32_t syncTime = 0; // time of last sync()



// the digital pins that connect to the LEDs
#define redLEDpin 2
#define greenLEDpin 3

// The analog pins that connect to the sensors

RTC_DS1307 RTC; // define the Real Time Clock object

// for the data logging shield, we use digital pin 10 for the SD cs line
const int chipSelect = 10;



void error(char *str)
{
//  Serial.print("error: ");
 // Serial.println(str);
  
  // red LED indicates error
//  digitalWrite(redLEDpin, HIGH);

 // while(1);
}

void setup(void)
{

  lcd.begin(16, 2);
  lcd.clear();
  lcd.print("Gav's Cal Test");
  delay(3000);

  
  // use debugging LEDs
  pinMode(redLEDpin, OUTPUT);
  pinMode(greenLEDpin, OUTPUT);
  

  // initialize the SD card
  lcd.clear();
  lcd.print("Initializing SD card...");
  // make sure that the default chip select pin is set to
  // output, even if you don't use it:
  pinMode(10, OUTPUT);
  
  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    error("Card failed, or not present");
  }
  lcd.clear();
  lcd.print("card initialized.");
  
 
  // connect to RTC
  Wire.begin();  
 
}
void loop(void)
{
  DateTime now;
RTC.adjust(DateTime(__DATE__, __TIME__));
 
  uint32_t m = millis();


  // fetch the time
  now = RTC.now();
  
  lcd.clear();
  lcd.print(now.day(), DEC);
    lcd.print("/");
  lcd.print(now.month(), DEC);
  lcd.print("/");
  lcd.print(now.year(), DEC);
  File dataFile = SD.open("test.txt");


  if (dataFile) {
    Serial.println("File Opened");
    lcd.clear();
       delay( 5 );  //LCD-specific M
      


  while (dataFile.available()) {
      Serial.write(dataFile.read());
      lcd.write(dataFile.read());
      lcd.print(dataFile.read());
    }
  dataFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println("error");
  }
  


  
}

Sad to say, if your uncle has Alzheimers, he will not know what the gadget is for!

I have done this code but it doesn't work.

It does something. You might want to describe what it does.

What it actually does is, obviously, not exactly what you want it to do. You might describe how what it does differs from what you want.

The actual project needs to be broken into pieces that you can perform. 1) Read a record from the file. 2) Scroll the message on the LCD.

When you have these two parts working, as functions, it is easy to call them in a while loop, reading all the records in the file, and scrolling them.

Then, add a function to compare the date in the record to today's date. That will require, of course, another function to get today's date (and an RTC), and another function to extract the date from the record (using strtok(), if you are smart and use NULL terminated arrays of chars instead of Strings).

If the dates are the same, scroll the message. If not, just discard it.