Mikroelektronika MIKROE-442 데이터 시트
538
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
Library Example
Default Pin Configuration
Use
SPI_Lcd_Init
for default pin settings (see the first figure below).
Copy Code To Clipboard
program Spi_Lcd
dim text as char[16]
dim counter as byte
‘ Port Expander module connections
dim SPExpanderRST as sbit at LATF0_bit
dim SPExpanderCS as sbit at LATF1_bit
dim SPExpanderRST_Direction as sbit at TRISF0_bit
dim SPExpanderCS_Direction as sbit at TRISF1_bit
‘ End Port Expander module connections
sub procedure Move_Delay() ‘ Function used for text moving
Delay_ms(500) ‘ You can change the moving speed here
end sub
main:
text = “mikroElektronika”
ADPCFG = 0xFFFF ‘ initialize AN pins as digital
SPI1_Init() ‘ Initialize SPI
Spi_Lcd_Config(0) ‘ Initialize LCD over SPI interface
Spi_Lcd_Cmd(_LCD_CLEAR) ‘ Clear display
Spi_Lcd_Cmd(_LCD_CURSOR_OFF) ‘ Turn cursor off
Spi_Lcd_Out(1,6, “mikroE”) ‘ Print text to LCD, 1st row, 6th column
Spi_Lcd_Chr_CP(“!”) ‘ Append ‘!’
Spi_Lcd_Out(2,1, text) ‘ Print text to LCD, 2nd row, 1st column
‘ Spi_Lcd_Out(3,1,’mikroE’) ‘ For LCD with more than two rows
‘ Spi_Lcd_Out(4,15,’mikroE’) ‘ For LCD with more than two rows
‘ Moving text
for counter = 0 to 3 ‘ Move text to the right 4 times
Spi_Lcd_Cmd(_LCD_SHIFT_RIGHT)
Move_Delay()
next counter
while TRUE ‘ Endless loop
for counter = 0 to 6 ‘ Move text to the left 7 times
Spi_Lcd_Cmd(_LCD_SHIFT_LEFT)
Move_Delay()
next counter
for counter = 0 to 6 ‘ Move text to the right 7 times
Spi_Lcd_Cmd(_LCD_SHIFT_RIGHT)
Move_Delay()
next counter
wend
end.