Go Down

Topic: How to use an SD Card Module with an LCD Keypad Shield? (Read 700 times) previous topic - next topic



I'm using Arduino Uno, my problem is related to an SD Card Module with an LCD Keypad Shield.

On my SD card is currently a test.txt file, with a text 'tsp'. I can read it and print it on my Serial Monitor, but when I write it in my code that I want to print it on my LCD I get '-1' on the LCD Display and 'tp' (without the 's' in the middle) on my Serial Monitor.

On the beginning of my sketch you can see how I wired the SD:

Code: [Select]
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS  - pin 3
#include <LiquidCrystal.h>
#include "LCDKeypad.h"
#include <SPI.h>
//#include <SD.h>
#include "SdFat.h"
SdFat SD;

LiquidCrystal lcd(8,9,4,5,6,7);  

#define SD_CS_PIN 3
File myFile;

void setup() {
  // Open serial communications and wait for port to open:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
    lcd.begin(16,2);  //Initialize a 2x16 type LCD

  Serial.print("Initializing SD card...");

  if (!SD.begin(SD_CS_PIN)) {
    Serial.println("initialization failed!");
  Serial.println("initialization done.");

  // open the file. note that only one file can be open at a time,

  // re-open the file for reading:
  myFile = SD.open("test.txt");
  if (myFile) {

    // read from the file until there's nothing else in it:
    while (myFile.available()) {
    // close the file:
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");

void loop() {
  // nothing happens after setup

Thanks in forward for the help,



I too am having issues using an Arduino Uno variant with LCD displays and an Adafruit datalogger shield. I will detail all in a new post.





try 'write' to lcd  (instead of 'print')
Hi knut_ny, thanks to your response.
When I try to use write instead print I get a black square.
I also tried to put out rows with Serial.print inside if(myFile) and for lcd.print I get '10' and for write also undefined character.

Go Up