Mikroelektronika MIKROE-724 Scheda Tecnica

Pagina di 726
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
379
Library Example
The following code demonstrates usage of the Lcd Library routines:
Copy Code To Clipboard 
program  Lcd_Test
‘ LCD module connections
dim LCD_RS as sbit at LATD0_bit
dim LCD_EN as sbit at LATD1_bit
dim LCD_D4 as sbit at LATB0_bit
dim LCD_D5 as sbit at LATB1_bit
dim LCD_D6 as sbit at LATB2_bit
dim LCD_D7 as sbit at LATB3_bit
dim LCD_RS_Direction as sbit at TRISD0_bit
dim LCD_EN_Direction as sbit at TRISD1_bit
dim LCD_D4_Direction as sbit at TRISB0_bit
dim LCD_D5_Direction as sbit at TRISB1_bit
dim LCD_D6_Direction as sbit at TRISB2_bit
dim LCD_D7_Direction as sbit at TRISB3_bit
‘ End LCD module connections
dim txt1 as char[16]
    txt2 as char[9]
    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:
  ADPCFG = 0xFFFF                  ‘ Configure AN pins as digital I/O
  txt1 = “mikroElektronika”
  txt2 = “EasydsPIC4A”
  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,3,txt2)                ‘ Write text in second row