User manual

324
mikoBasic PRO for PIC32
MikroElektronika
Library Example
The following code demonstrates usage of the Lcd Library routines:
Copy Code To Clipboard
// LCD module connections
dim LCD_RS as sbit at LATB2_bit
dim LCD_EN as sbit at LATB3_bit
dim LCD_D4 as sbit at LATB4_bit
dim LCD_D5 as sbit at LATB5_bit
dim LCD_D6 as sbit at LATB6_bit
dim LCD_D7 as sbit at LATB7_bit
dim LCD_RS_Direction as sbit at TRISB2_bit
dim LCD_EN_Direction as sbit at TRISB3_bit
dim LCD_D4_Direction as sbit at TRISB4_bit
dim LCD_D5_Direction as sbit at TRISB5_bit
dim LCD_D6_Direction as sbit at TRISB6_bit
dim LCD_D7_Direction as sbit at TRISB7_bit
// End LCD module connections
dim txt1 as char[16]
txt2 as char[12]
txt3 as char[8]
txt4 as char[7]
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:
CHECON = 0x32
AD1PCFG = 0xFFFF ‘ Congure AN pins as digital I/O
txt1 = “mikroElektronika”
txt2 = “LV32MX v6”
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 rst 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 rst 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