help in scrolling the text on lcd

General discussion on mikroC.
Post Reply
Author
Message
muza1988
Posts: 9
Joined: 11 Jun 2010 11:37

help in scrolling the text on lcd

#1 Post by muza1988 » 23 Jun 2010 08:03

hi

i am using PIC 16f877A and 2x16 LCD. i want to scroll the text across the lcd (left to right). i already wrote code to display the text but i dnt know how to scroll it. plz help me.

Code: Select all

void main()
{



  LCD_Config(&PORTD,1,0,2,7,6,5,4);           // LCD pins that are connected to PIC at PORTD
  LCD_Cmd(LCD_CLEAR);
  LCD_Out(1,1, "WELCOME TO");           // Print text to LCD, 1st row, 1st column
  Delay_ms(1000);
  LCD_Out(2,1,"ENGINUS");



 }






User avatar
tihomir.losic
mikroElektronika team
Posts: 2138
Joined: 02 Dec 2009 14:16
Location: Serbia
Contact:

Re: help in scrolling the text on lcd

#2 Post by tihomir.losic » 25 Jun 2010 12:35

Hello,

please, try this code (used: PIC16F877A and EasyPIC6):

Code: Select all

char *text = "mikroElektronika";
char i;

void Move_Delay() {                  // Function used for text moving
  Delay_ms(500);                     // You can change the moving speed here
}

void main() {
  Lcd_Config(&PORTB, 4, 5, 6, 3, 2, 1, 0);        // Lcd_Init_EP6, see Autocomplete

  LCD_Cmd(LCD_CLEAR);                // Clear display
  LCD_Cmd(LCD_CURSOR_OFF);           // Turn cursor off
  LCD_Out(1,1, text);                // Print text to LCD, 1st row, 1st column
  Delay_ms(1000);
  LCD_Out(2,6,"mikroE");             // Print text to LCD, 2nd row, 6th column

  for(i=0; i<4; i++) {               // Move text to the right 4 times
    Lcd_Cmd(LCD_SHIFT_RIGHT);
    Move_Delay();
  }

  while(1) {                         // Endless loop
    for(i=0; i<8; i++) {             // Move text to the left 7 times
      Lcd_Cmd(LCD_SHIFT_LEFT);
      Move_Delay();
    }

    for(i=0; i<8; i++) {             // Move text to the right 7 times
      Lcd_Cmd(LCD_SHIFT_RIGHT);
      Move_Delay();
    }
  }
}
Best regards,

Losic Tihomir
mikroElektronika [Support team]

Post Reply

Return to “mikroC General”