I have a 4x20 LCD with a serial backpack (2.0 version by John Mardock). I want to scroll a message from right to left. The following code works however, unless I set the delay >500ms, the text gets badly distorted and 'flickery' as it moves. Ideally I'd like it to scroll at a rate of 50 to 100ms.
// Scroll a message from right to left across
// a serial LCD display
// Serial to parallel adapter by John Mardock
char *msg = " HELLO"; // 20 characters init position
char *p = NULL; //init Pointer
int x = 0; //init Pointer index
void setup()
{
Serial.begin(9600); // open the serial port at 9600 bps: \
Serial.print("?G420"); // set disp to 4 rows X 20 chars
Serial.print("?f"); // clear screen
delay(1000); // wait for LCD to fully init
p = &msg[0]; //Set Pointer init position to 0
}
void loop()
{
Serial.print("?f"); // clear screen
p = &msg[x]; //set new pointer position
for (int i=0; i<19; i++)
{
Serial.print(*p);
p++;
}
delay(100);
x++;
if (x>19)
{
x=0;
}
}
Am I going about this the right way or is there a better way?
Would the display respond better if I went straight parallel instead of the serial backpack?
I know my code is not the best so any help on optimizing would be greatly appreciated!!! :
Thank you!!
Hank