Im trying to read text in SD card and display on the LCD but it display 2 weird characters after the text. What is it and why does it show up?
Here is my code:
I attached a picture of what it looks like
Here is my code:
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);
lcd.print(cr);
if(cr == '\n'){
break;
}
}
}
Attachments
-
48.5 KB Views: 18
Last edited by a moderator: