0

i am working for a project based on lifi using arduino and i need to diplay content of sd card to lcd i tried a lot some online programs also i tried but there is a simple blank screen. one of the code i used is this:

CODE:
#include <SD.h>
#include <SPI.h>

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7);

File myFile;
const int CSpin = 10;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(CSpin, OUTPUT);
  SD.begin(CSpin);

  lcd.begin(20,4);
  lcd.setBacklightPin(3, POSITIVE);
  lcd.setBacklight(HIGH);
}

void loop() {
  // put your main code here, to run repeatedly:
  lcd.setCursor(0,0);
  ReadLine();
  myFile.close();
}

void ReadLine(){
  myFile = SD.open("Sample.txt", FILE_READ);
  myFile.seek(0);
  char cr;
  for(unsigned int i = 0; i < (3 - 1);){
    cr = myFile.read();
    if(cr == '\n')
      {
        i++;
      }
  }

  while(true){
    cr = myFile.read();
    Serial.write(cr);
   
    if(cr == '\n'){
      break;
    }
    //here...
    else if(cr >= 0x20 && cr <= 0x7E){
      lcd.print(cr);
    }
   
  }
}

displays blank screen Please help me out!! Any other working program also would work.!! Thanks in advance.

4
  • 2
    How you managed to get just the display to work at all with one of the library examples without dealing with SD cards? – timemage Mar 28 at 16:09
  • sir i am really sorry i didnt get you!! . sir this code is copied from online i haven't coded sir could you please tell me what can i do to make it working!!! thanks sir in advance – Raj Mobilestore Mar 28 at 17:37
  • 1
    The LiquidCrystal_I2C library will have examples available under the File/Examples menu. With your SD card hardware disconnected, do any of these examples work? – timemage Mar 29 at 12:43
  • yes that example works perfectly sir!! – Raj Mobilestore Mar 31 at 5:04
1

Well The Do You Really Have an i2c module connected to the display you can find this out by checking how many pins the display has if it is not four pins then you need the LiquidCrystal Library If Not Then The Arguments Passed To The LiquidCrystal I2c Function Should Be The Address Witch Should Be 0x27 If You Did Not Modify The i2c Module(Next Time Give The Circuit Schmatics )

3
  • WTH New Contributor Thats Rude! – Harsha Addanki Mar 30 at 16:31
  • yes sir it has 4 pins and adress is also 0x27 !! – Raj Mobilestore Mar 31 at 5:06
  • sir could you provide the schematics pls?? because the above code is copied from google sir and this is a part of my project sir!! main is my lifi tech!! this is just to display content of sd card ! – Raj Mobilestore Mar 31 at 5:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.