using LCD and SD at a time

i am using a arduino uno with SD card and LCD screen ,there is aproblem like the information is printed to SD but is not displayed in the LCD it is only displayed when MISO pin of arduino is disconnected can i use both at a time using any acknowledgements please help me to give acknowledgement and use both of them at a time

the code is

switch

{
case:1
{
lcd.print("ABCDEG");
lcd.print("hello, world!");

File dataFile = SD.open("datalog.txt", FILE_WRITE);

if (dataFile) {
dataFile.println("HEllo World");
dataFile.close();

}
}

SravanKumar:
i am using a arduino uno with SD card and LCD screen ,there is aproblem like the information is printed to SD but is not displayed in the LCD it is only displayed when MISO pin of arduino is disconnected can i use both at a time using any acknowledgements please help me to give acknowledgement and use both of them at a time

the code is

switch 

{
case:1
{
lcd.print("ABCDEG");
lcd.print("hello, world!");

File dataFile = SD.open("datalog.txt", FILE_WRITE);

if (dataFile) {
   dataFile.println("HEllo World");
   dataFile.close();

}
 }

please use the code markup tags, </> is icon to insert these tags, it makes your posts easier to read.
[ code ]
program code between the tags, there should not be any spaces in the tags
[ / code ]

I cannot answer your question because I need more information from you.

  • What hardware are you using?
    just saying LCD and SD does not describe the actual hardware in enough detail.
    Is your LCD conneced using I2C, SPI, Serial?
    What library are you using? LiquidCrystal, LiquidCrystalI2c, or directly bit banging a 4bit IF?
  • How have you connected it? a schematic please?
  • include a complete Arduino sketch that shows the problem you are having.

Without this information I cannot guess what is wrong.

Chuck.

im using a LCD , sdn= card module and a rtc ds1307, RTC is interfaced through A4,A5(i2c) to arduino uno, memory card through the ICSP pins, im enclosing the code please help me.

#include <Keypad.h>
#include <LiquidCrystal.h>
#include <SPI.h>
#include<SD.h>
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 rtc;
File file;
int CS_PIN=7;
char p; 
const byte ROWS = 3; // 3 rows
const byte COLS = 3; // 3 columns
// Define the Keymap
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},{'I','8','E'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = {A3, 9, 8};
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = {A0,A1,A2}; 

// Create the Keypad
Keypad kpd = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS );

LiquidCrystal lcd(12,13,5,4,3,2);
int text,clas=0;
void setup()  
{
Serial.begin(9600);
delay(1000);

initializeSD();
delay(1000); 
Wire.begin();
rtc.begin();

if (! rtc.isrunning()) 
{
Serial.println("RTC is NOT running!");
rtc.adjust(DateTime(2015,6,29,13,10,0));
  }
    // following line sets the RTC to the date & time this sketch was compiled
delay(1000);
createFile("stack.csv"); 
file.close();
lcd.begin(16,2);

delay(1000); // delay 1s to stabilize serial ports
}
void loop() 
{
  DateTime now = rtc.now();
delay(1000);
Serial.println(file);

char key=kpd.getKey();
if(key)
  {
switch(key)
    {
case '1':
      {

file = SD.open("stack.csv", FILE_WRITE);
Serial.println(file);
  // if the file is available, write to it:
if (file) 
  {
delay(2000);

file.print("Mr.G.Srinivas Raju,"  );
file.print("W C N,");

Serial.println("G.Srinivas Raju    ");
file.close();
delay(3000);
lcd.clear();
lcd.setCursor(0, 0); // top left
lcd.write("Mr.G.Srinivas Raju");
lcd.setCursor(0, 1); // bottom left
lcd.write("W C N");
delay(3000);

  }
break;
              }
case '2':
      {
       
file = SD.open("stack.csv", FILE_WRITE);
Serial.println(file);
  // if the file is available, write to it:
if (file) {
delay(2000);
file.print("Mr.P.Praveen Kumar,");
file.print(" C M C,");
Serial.print("Mr.P.Praveen Kumar");
file.close();
lcd.clear();
lcd.setCursor(0, 0); // top left
lcd.write("Mr.P.Praveen Kumar");
lcd.setCursor(0, 1); // bottom left
lcd.write("C M C");
delay(3000);

}
break;   
      }
      case '3':
      {

file = SD.open("stack.csv", FILE_WRITE);
Serial.println(file);
  // if the file is available, write to it:
if (file)
  {
delay(2000);
file.print("Mr.M.Shiva Kumar,");
file.print("Internetworking,");
    // print to the serial port too:
Serial.println("M.Shiva Kumar ");
file.close();
lcd.clear();
lcd.setCursor(0, 0); // top left
lcd.write("Mr.M.Shiva Kumar");
lcd.setCursor(0, 1); // bottom left
lcd.write("INT.NET");
delay(3000);

  }
  break;   
      }
            case '4':
      {

file = SD.open("stack.csv", FILE_WRITE);
Serial.println(file);
  // if the file is available, write to it:
if (file)
  {
delay(2000);
file.print("Substitute,");

    // print to the serial port too:
Serial.println("Substitute ");
file.close();
lcd.clear();
lcd.setCursor(0, 0); // top left
lcd.write("SUBSTITUTE");

delay(3000);
  }
break;   
      }
case 'I':
      { 
        Serial.println("I selected");
     
lcd.clear();
lcd.clear();
lcd.setCursor(0, 0);
lcd.write("PLEASE ENTER");
lcd.setCursor(0, 1); // bottom left
lcd.write("YOUR ID...");   
file = SD.open("stack.csv", FILE_WRITE);
Serial.println(file);
  // if the file is available, write to it:
if (file) 
  { 
delay(2000); 
file.print(now.year(), DEC);
file.print('/');
file.print(now.month(), DEC);
file.print('/');
file.print(now.day(), DEC);
file.print(",");
file.print(now.hour(), DEC);
file.print(':');
file.print(now.minute(), DEC);
file.print(':');
file.print(now.second(), DEC);
file.print(",");
file.close();
        }break;
              
      }
case 'E':
      {
     
lcd.clear();

lcd.write("SESSION COMPLETE");
delay(3000);
lcd.clear();
SD.begin();
file = SD.open("stack.csv", FILE_WRITE);
Serial.println(file);
  // if the file is available, write to it:
if (file) {
delay(2000);

file.print(now.hour(), DEC);
file.print(':');
file.print(now.minute(), DEC);
file.print(':');
file.print(now.second(), DEC);
file.print("\n");
file.close();
}

break;
      }
default: lcd.write("wrong Key");
      }
  }}

void initializeSD()
{
Serial.println("Initializing SD card...");
pinMode(CS_PIN, OUTPUT);

if (SD.begin())
  {
Serial.println("SD card is ready to use.");
  } else
  {
Serial.println("SD card initialization failed");
return;
  }
}

int createFile(char filename[])
{
file = SD.open(filename, FILE_WRITE);

if (file)
  {
Serial.println("File created successfully.");
return 1;
  } else
  {
Serial.println("Error while creating file.");
return 0;
  }
}
LiquidCrystal lcd(12,13,5,4,3,2);

Your LCD is not an SPI device. You can not use the SPI pins to talk to it and to an SPI device (the SD reader IS an SPI device) at the same time.

thank u ,can u suggest me what pins can i use for the lcd

SravanKumar:
thank u ,can u suggest me what pins can i use for the lcd

Any pins that are not being used by anything else. The SD shield is using 10 to 13 plus the slave select pin. Serial is using 0 and 1. With the keypad using 8 and 9 and 4 of the analog pins, that leaves only 2, 3, 5, 6, 7, A4 and A5. That looks like enough pins, unless you have an I2C device in the mix, using A4 and A5. If you do, you need a different Arduino.