Hello there
please i am working on a project that accepts serial data and displays it on a 16x2 LCD
am using an arduino mega.
the first line is a predefined text while the second line takes the text from the serial port and displays it.
1. i want to make the text scroll if the length of the serial data exceeds 16 characters (i.e longer that lcd's line)
2. ONLY the second line should scroll
Regards,
IRshaad
my code till now;
--------------------------------------------------------------------
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
String textLCD = "";
int textlength = textLCD.length();
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.write("LCD Display Demo");
}
void loop()
{
if (Serial.available())
{
delay(100);
lcd.clear();
lcd.setCursor(0, 0);
lcd.write("Text from Serial:");
lcd.setCursor(0, 1);
while (Serial.available() > 0) {
lcd.write(Serial.read()); // ONLY THIS LINE SHOULD SCROLL IF THE LENGTH EXCEEDS 16 CHARACTERS
}
}
}