Hi everyone, I'm trying to create a simple code to have a char array get printed to the first line of an LCD with new information. Then when more new information comes up I want it published to the first line and what was previously on the first line get moved down to the second line so forth and so on. I'm having an issue with char arrays mainly because I am so new with arduino I don't quite understand them. Hopefully you can help me out. Here is a super simplified version of my code.
#include <LiquidCrystal_I2C.h>
char Line1[21];
char Line2[21];
char Line3[21];
char Line4[21];
char NewInfo[21];
LiquidCrystal_I2C lcd(0x27, 20, 4);
void setup()
{
Serial.begin(115200);
lcd.begin();
lcd.backlight();
lcd.clear();
}
void LCDPrint()
{
Line4[21] = Line3[21];
Line3[21] = Line2[21];
Line2[21] = Line1[21];
Line1[21] = NewInfo[21];
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(Line1);
lcd.setCursor(0, 1);
lcd.print(Line2);
lcd.setCursor(0, 2);
lcd.print(Line3);
lcd.setCursor(0, 3);
lcd.print(Line4);
}
void loop()
{
NewInfo[21] = {'Test1'};
LCDPrint();
delay(1000);
NewInfo[21] = {'Test2'};
LCDPrint();
delay(1000);
NewInfo[21] = {'Test'};
LCDPrint();
delay(1000);
NewInfo[21] = {'Test4'};
LCDPrint();
delay(1000);
}