Mikroelektronika MIKROE-350 データシート

ページ / 526
Library Example
The following code demonstrates usage of the Lcd Library routines:
' LCD module connections
dim LCD_RS as sbit at PORTD.2
dim LCD_EN as sbit at PORTD.3
dim LCD_D4 as sbit at PORTD.4
dim LCD_D5 as sbit at PORTD.5
dim LCD_D6 as sbit at PORTD.6
dim LCD_D7 as sbit at PORTD.7
dim LCD_RS_Direction as sbit at DDRD.B2
dim LCD_EN_Direction as sbit at DDRD.B3
dim LCD_D4_Direction as sbit at DDRD.B4
dim LCD_D5_Direction as sbit at DDRD.B5
dim LCD_D6_Direction as sbit at DDRD.B6
dim LCD_D7_Direction as sbit at DDRD.B7
' End Lcd module connections
dim txt1 as char[17]
txt2 
as char[10]
txt3 
as char[9]
txt4 
as char[8]
i    
as byte  
' Loop variable
sub procedure Move_Delay() ' Function used for text moving
Delay_ms(500)           ' You can change the moving speed here
end sub
main:
txt1 = "mikroElektronika"
txt2 = "EasyAVR5A"
txt3 = "Lcd4bit"
txt4 = "example"
Lcd_Init()                        ' Initialize Lcd
Lcd_Cmd(LCD_CLEAR)                ' Clear display
Lcd_Cmd(LCD_CURSOR_OFF)           ' Cursor off
LCD_Out(1,6,txt3)                 ' Write text in first row
LCD_Out(2,6,txt4)                 ' Write text in second row
Delay_ms(2000)
Lcd_Cmd(LCD_CLEAR)                ' Clear display
LCD_Out(1,1,txt1)                 ' Write text in first row
LCD_Out(2,4,txt2)                 ' Write text in second row
Delay_ms(500)
' Moving text
for i=0 to 3              ' Move text to the right 4 times
245
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6