I am working on some code to scroll text marquee style
right to left then when it has scrolled all the way to the left off the screen I want it to stop.
there are scroll commands in the data sheet for my LCD
Scroll Right 0x1C
Scroll Left 0x18
however I have not been able to figure out how to use them.
here is the code I wrote to do this so far.
It works with a single character but if I add any more and it is buggy.
any help would be greatly appreciated.
#include <NewSoftSerial.h>
NewSoftSerial LCD(0,5); // serial LCD connected to pin #5
int y = 15; // for scroll
void setup(){
LCD.begin(9600);
}void loop()
{
goTo(y);
LCD.print(“X”);
y=y-1;if(y<0){
y=15;
}delay(250);
clearLCD();}
// Serial LCD COMMAND CODES
// Initiates a function command to the display
void serCommand() {
LCD.print(0xFE, BYTE);
}
// Resets the display, undoing any scroll and removing all text
void clearLCD() {
serCommand();
LCD.print(0x01, BYTE);
}
// Starts the cursor at the beginning of the first line (convienence method for goTo(0))
void selectLineOne() { //puts the cursor at line 0 char 0.
serCommand(); //command flag
LCD.print(128, BYTE); //position
}
// Starts the cursor at the beginning of the second line (convienence method for goTo(16))
void selectLineTwo() { //puts the cursor at line 0 char 0.
serCommand(); //command flag
LCD.print(192, BYTE); //position
}
// Sets the cursor to the given position
// line 1: 0-15, line 2: 16-31, 31+ defaults back to 0
void goTo(int position) {
if (position < 16) {
serCommand(); //command flag
LCD.print((position+128), BYTE);
} else if (position < 32) {
serCommand(); //command flag
LCD.print((position+48+128), BYTE);
} else {
goTo(0);
}
}