Hackster is hosting Hackster Holidays, Ep. 5: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 5 on Friday!
millerman4487
Published © CC BY-NC-SA

Reading Text Files From an SD Card (Arduino)

This project uses a micro SD card to store a text file and print it out to a 16x2 liquid crystal display.

IntermediateFull instructions provided1 hour23,698
Reading Text Files From an SD Card (Arduino)

Things used in this project

Story

Read more

Schematics

Breadboard Diagram

Code

Code

Arduino
#include <LiquidCrystal.h>
#include <SPI.h>
#include <SD.h>

File myFile;

const int rs = 2, en = 3, d4 = 7, d5 = 6, d6 = 5, d7 = 4; //lcd pins
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  if (!SD.begin(10)) { //make sure sd card was found
    while (true);
  }

  lcd.begin(16, 1);
  lcd.setCursor(0, 0);
  lcd.print("myfile.txt");
  delay(2000);
  lcd.clear();
}

void loop() {
  myFile = SD.open("myfile.txt"); // open the file for reading

  lcd.setCursor(16, 0); //
  lcd.autoscroll(); //enable auto-scrolling

  if (myFile) { 
    while (myFile.available()) { //execute while file is available
      char letter = myFile.read(); //read next character from file
      lcd.print(letter); //display character
      delay(300);
    }

    myFile.close(); //close file
  }

  lcd.clear();
}

myfile.txt

Plain text
Did you ever hear the Tragedy of Darth Plagueis the wise? I thought not. It's not a story the Jedi would tell you. It's a Sith legend. Darth Plagueis was a Dark Lord of the Sith, so powerful and so wise he could use the Force to influence the midichlorians to create life... He had such a knowledge of the dark side that he could even keep the ones he cared about from dying. The dark side of the Force is a pathway to many abilities some consider to be unnatural. He became so powerful... the only thing he was afraid of was losing his power, which eventually, of course, he did. Unfortunately, he taught his apprentice everything he knew, then his apprentice killed him in his sleep. It's ironic he could save others from death, but not himself.

Credits

millerman4487

millerman4487

10 projects • 82 followers
Contact

Comments

Please log in or sign up to comment.