Scroll LCD?


Closed Thread
Results 1 to 6 of 6

Thread: Scroll LCD?

  1. #1
    Join Date
    Nov 2009
    Location
    Wagoner, USA
    Posts
    52

    Default Scroll LCD?

    Does anyone know to scroll a 2 or a 4 line serial LCD with a PIC?

  2. #2


    Did you find this post helpful? Yes | No

    Default Here you go ...

    Hi Polymer

    Here you go , I am using an 18F4520 but this should work on any pic with a parallel LCD wired in 4 bit mode , just change the LCD defines as you need.

    Code:
    '*************************************
    'LCD demo with scrolling 
    '*************************************
    
    'Ocsillator selections here
            OSCCON = $70            'Int CLK 8MHz
            OSCTUNE.6 = 1           'PLL 4x
            ADCON1= %00001111       '$0F = disable A/D converter
            cmcon   =   7 
            INTCON2.7 = 0     'switch pull-ups ON
    'END of oscillator selections
      'timer/oscillator defines 
            DEFINE OSC 32            '4x 8MHz
    'END of timer/oscillator defines
    
    'Port IO directions and presets for port pins begin here
    'TRISX = %76543210   << tris bit order numbering
    'TRISA = %11111111       'All pins are outputs
    '// Define port pins as inputs and outputs ...
            TRISA  = %00000000 'example only - TRISB = %00001111 ;Make B4-B7 outputs, B0-B3 inputs, 
            TRISB = %11111111  'for 4x4 keypad all input
            TRISC = %10010000
            TRISD = %00000000
            TRISE.0 = 0
            TRISE.1 = 0
            TRISE.2 = 0
    'End of Port IO directions and presets for port pins begin here
    
                       
    'variables begin here
           
            counter0 var byte                 ' Byte for counter
            counter1 var byte                 ' Byte for second counter
    'end of variables
    
    'LCD defines begin here   
            DEFINE LCD_BITS 4 	'defines the number of data interface lines (4 or 8) 
            DEFINE LCD_DREG PORTD 	'defines the port where data lines are connected to
            DEFINE LCD_DBIT 4 	'defines the position of data lines for 4-bit interface (0 or 4)
            DEFINE LCD_RSREG PORTD 	'defines the port where RS line is connected to
            DEFINE LCD_RSBIT 2 	'defines the pin where RS line is connected to 
            DEFINE LCD_EREG PORTD 	'defines the port where E line is connected to 
            DEFINE LCD_EBIT 3 	'defines the pin where E line is connected 
            'DEFINE LCD_RWREG 0 	'defines the port where R/W line is connected to (set to 0 if not used)
            'DEFINE LCD_RWBIT 0 	'defines the pin where R/W line is connected to (set to 0 if not used)
            DEFINE LCD_COMMANDUS 2000 	'defines the delay after LCDOUT statement 
            DEFINE LCD_DATAUS 200 		'delay in micro seconds
    'END of LCD DEFINES
    
    'includes begin here
            INCLUDE "modedefs.bas"
            
    'end of includes
    
    'Main code begins here       
    
            Pause 500       ' LCD initialize time
     showtime:          
    
        lcdout $FE,1,"watch"        ' Clears LCD displays "watch"
        
            pause 1000                  ' Pause 1000ms
        
        lcdout $fe,1                ' Clears LCD sreen
        
        lcdout $FE,$C0,"my PIC"       ' Cursor to start of
                                    ' second line, displays "my PIC"       
        
            Pause 500                  ' Pause 1000ms
        
        lcdout $fe,$14,"scroll"       ' Cursor moves to right one 
                                    ' position and displays "scroll" 
        lcdout $fe,1                ' Clears LCD sreen
          
            pause 1000
             
             LCDOUT $fe, $80+17,"SCROLL"
             
             Pause 1000
             
         for counter0 = 1 to 28            ' FOR..NEXT loop so "scroll"
                                    ' scrolls off the LCD to the left
        
                lcdout $fe,24               ' Scrolls display one position to the left
        
                pause 150                   ' Pause 150 ms
         
                next counter0                     ' do loop again till max count
         
        
            pause 1000                  ' Pause 1000ms       
        
        lcdout $fe,1                ' Clears LCD       
        
        Pause 500
         LCDout $fe,1
        LCDout $fe,1,"AWESOME!!"        ' Clear and display "AWESOME!!"
        
            pause 1000                  ' Pause 1 sec
        
            for counter0 = 1 to 5             ' FOR..NEXT loop so "AWESOME!!" scrolls
                                    ' off LCD to the left
        
                lcdout $fe,24               ' Scrolls display one   ' position to the left
        
                pause 100                   ' Pause 100ms
         
            next                        ' do loop again till max count
        
        LCDout $fe,1,"Don't miss out!"' Clear LCD , display "Don't miss out!"
        
            pause 1000                  ' Pause 1000ms
        
        for counter0 = 1 to 16            ' FOR..NEXT loop so "Don't miss out!"
                                    ' scrolls off LCD to the right
        
                lcdout $fe,28               ' Scrolls display one 
                                    ' position to the right
         
                pause 100                   ' Pause 100ms
          
        next                        ' do loop again till max count
             
        for counter1 = 1 to 2             ' FOR..NEXT loop to display
                                    ' Keep watching! for a count of 2 loops
        
            LCDout $fe,1                ' Clear LCD screen
        
            LCDOUT $fe, $80+17,"Keep watching!"
                                    ' Display "Keep watching!" starting
                                    ' 17 positions from the beginning
                                    ' of the first line off LCD screen 
                                    
            pause 200                   ' Pause 200ms 
        
                for counter0 = 1 to 28            ' FOR..NEXT loop so "Keep watching!"
                                    ' scrolls off the LCD to the left
        
                lcdout $fe,24               ' Scrolls display one position to the left
        
                pause 150                   ' Pause 150 ms
         
                next counter0                    ' do loop again till max count 
        
        next counter1                     ' do loop again till max count
        
            Pause 500                   ' Pause 500ms
        
        goto showtime                  
         
        end
    And some codes for you
    Code:
    Control codes for HD44780 based displays:
    
    1 = Clear screen.
    2 = Send cursor to top-left position.
    8 = Blank without clearing.
    12 = Make cursor invisible/restore display if blanked.
    13 = Turn on visible blinking cursor.
    14 = Turn on visible underline cursor.
    16 = Move cursor one character left.
    20 = Move cursor one character right.
    24 = Scroll display one character left (all lines).
    26 = Poll Keypad
    28 = Scroll display one character right (all lines).
    35 = Place Large Digit
    58 = Enter Buffer Return Status Mode
    59 = Exit Buffer Return Status Mode
    61 = Make Vertical Bar Graph
    65 = Auto Transmit Keypresses on
    66 = Backlight On
    67 = Auto Line wrapping on.................(default).
    68 = Auto Line wrapping off.
    69 = Clear Key Buffer
    70 = Backlight Off
    71 = Go to position.
    72 = Go to top left.
    74 = Cursor on.
    75 = Cursor off.................................(default).
    76 = Cursor left.
    77 = Cursor right.
    78 = Create Custom Character
    79 = Auto Transmit Keypresses Off
    80 = Contrast
    81 = Auto scroll on.
    82 = Auto scroll off..........................(default).
    83 = Blink on.
    84 = Blink off (default).
    85 = Set Debounce Time
    86 = General purpose output on.
    87 = General purpose output off........(default).
    88 = Clear display.
    96 = Auto Repeat Mode Off
    104 = Initialize Horizontal Bar Graph
    110 = Initialize Large Digits
    115 = Initialize Thin Bar Vertical Graph
    118 = Initialize Thick Vertical Bar Graph
    124 = Make Horizontal Bar Graph
    126 = Auto Repeat Mode On
    192 = Move cursor to first position on second line.
    
    Use it with [ $FE,code ], like LcdOut $FE,1 - clear LCD ...
    Hope this helps -- post back updates if you add more funky routines.

    Kind regards
    Dennis

  3. #3
    Join Date
    Nov 2009
    Location
    Wagoner, USA
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Thanks. That helps a lot.
    Jerry

  4. #4
    Join Date
    May 2004
    Location
    brighton
    Posts
    149


    Did you find this post helpful? Yes | No

    Smile RE:Scroll LCD?


  5. #5


    Did you find this post helpful? Yes | No

    Default Awesome

    Nice one Isaac :-)

    Thanks for resurrecting it :-)


    Dennis

  6. #6
    Join Date
    Feb 2007
    Posts
    55


    Did you find this post helpful? Yes | No

    Default

    Nice post & thanks for sharing Dennis

Similar Threads

  1. Is this code not initialising the LCD properly?
    By Platypus in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 30th January 2010, 19:14
  2. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  3. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  4. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07
  5. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts