For a recent project of mine I wanted to scroll the screen of the LCD either Right or Left so the text will scroll across the screen..
Here are some commands I added:
- Code: Select all
Public Const
cmdDisplayRight = %00011100,
cmdDisplayLeft = %00011000
So when I wanted to make the screen scroll I just called the command like this:
- Code: Select all
Command(cmdDisplayLeft)
Full code can be found here:
- Code: Select all
// Device and Clock
Device = 18F452
Clock = 20
// LCD optional settings
#option LCD_DATA = PORTC.4 // LCD setup data port (sets it to 4 data lines only)
#option LCD_RS = PORTE.0
#option LCD_EN = PORTE.1
// Modules
Include "LCD.bas" // include LCD module
// LCD special Commands to shift LCD screen left and right.
Public Const
cmdDisplayRight = %00011100,
cmdDisplayLeft = %00011000
// Delay for LCD and Ports setup
DelayMS(200) // Allow LCD to warm up
ADCON1 = $07 // Make all pins digital I/O's - check datasheet
TRISA = %111111 // Make PORTA all inputs
TRISB = %11111111 // Make PORTB all inputs
TRISC = %00000000 // Make PORTC all outputs
TRISD = %00000000 // Make PORTD all outputs
TRISE = %000 // Make PORTE all outputs
// clear LCD before we start and then write our data
LCD.Cls // Clear the LCD screen
// Main Program Here.
While true // Main program loop that is multi-tasked
LCD.WriteAt(1,2,"Hello World!") // Send text to the LCD screen
Command(cmdDisplayLeft) // Scrolls the text left along LCD
DelayMS(380) // delay to display the text on the LCD
Wend







