Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This is a function that prints the information for chapter, event and line. Line is a value that indicates which line of the information is being scrolled through, and
- void printInfo(byte c, byte e, byte l) { //Take info of chapter, event, and line
- Serial.print(F("Function Called: ")); //debugging, terrible, oh well it'll be gone soon
- Serial.print(c);
- Serial.print(F(""));
- Serial.print(e);
- Serial.print(F(" "));
- Serial.println(l);
- String fileString; //create a string to hold the file name to read from the SD card
- char fileName[10] = {0};
- char sdChar; //create a character to store for later use (you'll see it)
- fileString = String(String(c) + String(e) + String(l) + ".txt"); //create a file name String
- Serial.println(fileString); //debugging
- fileString.toCharArray(fileName, 10); //convert it into a format that the SD library can work with
- Serial.println(fileName);
- sdData = SD.open(fileName); //open the file
- if(!sdData) { //check if file exists
- Serial.print(F("Error! File "));
- Serial.print(fileName);
- Serial.println(F(" not found!"));
- }
- lcd.clear(); //clear the LCD as we are writing a new page
- lcd.setCursor(0,0); //reset cursor
- delay(10); //little bit of delay to allow anything to catch up
- for(int x; x < 16; x++) { // this is a 16x2 lcd so make sure we stay within the bounds - files contain one line of text, 16 characters
- while(sdData.available()){ //wait for SD to become available if it isn't already
- sdChar = sdData.read(); //
- Serial.print(sdChar);
- lcd.setCursor(x, 0); //set the cursor to the right spot
- lcd.print(sdChar); //print the character to the lcd
- delay(5); //for cool effect
- }
- }
- sdData.close(); //close the file
- l = l + 1; //Increase the line by one and get ready to print the next thing - it reads the next file over and prints it on the next line
- fileString = String(String(c) + String(e) + String(l) + ".txt"); //create a file name String
- fileString.toCharArray(fileName, 10); //convert it into a format that the SD library can work with
- Serial.println();
- Serial.println(fileString);
- Serial.println(fileName);
- //now do that stuff before, all over again!
- sdData = SD.open(fileName); //open the file
- if(!sdData) { //check if file exists
- Serial.print(F("Error! File "));
- Serial.print(fileName);
- Serial.println(F(" not found!"));
- }
- lcd.clear(); //clear the LCD as we are writing a new page
- lcd.setCursor(0,1);
- delay(10);
- for(int x; x < 16; x++) {
- while(sdData.available()){
- sdChar = sdData.read();
- lcd.setCursor(x, 1); //set the cursor to the right spot
- lcd.print(sdChar);
- delay(5); //for cool effect
- }
- }
- sdData.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment