Scrolling text with Sparkfun 16*2 LCD (need help)


i working on code scroll text marquee style
right left when has scrolled way left off screen want stop.

there scroll commands in data sheet lcd
scroll right 0x1c
scroll left 0x18
however have not been able figure out how use them.

here code wrote far.
it works single character if add more , buggy.

any appreciated.

quote
#include <newsoftserial.h>


newsoftserial lcd(0,5); // serial lcd connected pin #5

int y = 15; // 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 function command display
     void sercommand() {
         lcd.print(0xfe, byte);
         }
   // resets display, undoing scroll , removing text
     void clearlcd() {
          sercommand();
          lcd.print(0x01, byte);
        }
   // starts cursor @ beginning of first line (convienence method goto(0))
     void selectlineone() {  //puts cursor @ line 0 char 0.
          sercommand();   //command flag
          lcd.print(128, byte);    //position
       }
   // starts cursor @ beginning of second line (convienence method goto(16))
     void selectlinetwo() {  //puts cursor @ line 0 char 0.
          sercommand();   //command flag
          lcd.print(192, byte);    //position
       }
       // sets cursor given position
   // line 1: 0-15, line 2: 16-31, 31+ defaults 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);
     }
   }

ok think solved problem... here code now
it works correctly when put spaces in front of text need figure out how remove them golden.

code: [select]
#include <newsoftserial.h>


newsoftserial lcd(0,5); // serial lcd connected pin #5

char line1[] = "               01234567890abcde";
#define line1length (sizeof(line1)-2)

int x = 15; // scroll
int y = 0; // scroll

void setup(){
 lcd.begin(9600);
}

void loop()
{
 if(x<16+y){
 lcd.print(line1[x]);
 }
 x++;
       
 if(x>line1length){
   y++;
   x=0+y;
   
   goto(y);
   delay(300);
   clearlcd();
 }
 if (y>line1length){
   y = 0;
 }
 
 
 

}
 
 



// serial lcd command codes
   // initiates function command display
     void sercommand() {
         lcd.print(0xfe, byte);
         }
   // resets display, undoing scroll , removing text
     void clearlcd() {
          sercommand();
          lcd.print(0x01, byte);
        }
   // starts cursor @ beginning of first line (convienence method goto(0))
     void selectlineone() {  //puts cursor @ line 0 char 0.
          sercommand();   //command flag
          lcd.print(128, byte);    //position
       }
   // starts cursor @ beginning of second line (convienence method goto(16))
     void selectlinetwo() {  //puts cursor @ line 0 char 0.
          sercommand();   //command flag
          lcd.print(192, byte);    //position
       }
       // sets cursor given position
   // line 1: 0-15, line 2: 16-31, 31+ defaults 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);
     }
   }



Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Scrolling text with Sparkfun 16*2 LCD (need help)


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums