$regfile = "m8def.dat" $crystal = 16000000 Config Lcdpin = Pin , Rs = Portd.0 , E = Portd.1 , E2 = Portd.2 , Db4 = Portd.3 , Db5 = Portd.4 , Db6 = Portd.5 , Db7 = Portd.6 Config Lcd = 40 * 4 Config Lcdmode = Port Config Lcdbus = 4 Const Pcf8574_lcd = &H40 'Defines the address of the I/O expander for LCD Const Rs = 4 Const Rw = 5 Const E2 = 6 Const E1 = 7 Config Scl = Portc.5 'Configure i2c SCL Config Sda = Portc.4 'Configure i2c SDA Config I2cdelay = 8 Declare Sub Lcd_init Declare Sub Lcd_init1 Declare Sub Lcd_reg(byval R As Integer) Declare Sub Lcd_char(g As Integer) Declare Sub Lcd_txt(t As String) Dim G As Integer Dim F As Integer Dim H As Integer Dim D As Integer Dim E As Integer Dim T As String * 27 Dim L As String * 1 Dim ___lcdno As Byte ' Put your own strings here Lcd_init1 Wait 2 Call Lcd_init ___lcdno = 0 Starte: T = "abcdef" Cls Home Lcd T Call Lcd_txt(t) Wait 2 Goto Starte ' Subroutine to initialise the LCD-display Sub Lcd_init I2cstop Waitms 100 I2cstart I2cwbyte Pcf8574_lcd ' PCF8574A to LCD Waitms 30 '15 Call Lcd_reg(&H03) Waitms 6 '4 Call Lcd_reg(&H03) Waitus 200 'waitms 1 Call Lcd_reg(&H03) Waitms 6 '4 Call Lcd_reg(&H02) Waitms 1 Call Lcd_reg(&H02) Call Lcd_reg(&H08) Waitms 1 Call Lcd_reg(&H00) Call Lcd_reg(&H08) Waitms 1 Call Lcd_reg(&H00) Call Lcd_reg(&H0c) Waitms 1 Call Lcd_reg(&H00) Call Lcd_reg(&H01) Waitms 1 I2cstop End Sub ' Subroutine to send a string to the LCD-display Sub Lcd_txt(t As String) I2cstart I2cwbyte Pcf8574_lcd ' PCF8574A to LCD F = 0 For E = 1 To Len(t) L = Mid(t , E , 1) If L = "\" Then F = 1 Else If F = 0 Then G = Asc(l) Call Lcd_char(g) Else If L = "A" Then Call Lcd_reg(&H00) Call Lcd_reg(&H01) Elseif L = "B" Then Call Lcd_reg(&H00) Call Lcd_reg(&H02) Elseif L = "C" Then Call Lcd_reg(&H00) Call Lcd_reg(&H04) Elseif L = "D" Then Call Lcd_reg(&H00) Call Lcd_reg(&H05) Elseif L = "E" Then Call Lcd_reg(&H00) Call Lcd_reg(&H06) Elseif L = "F" Then Call Lcd_reg(&H00) Call Lcd_reg(&H07) Elseif L = "G" Then Call Lcd_reg(&H00) Call Lcd_reg(&H08) Elseif L = "H" Then Call Lcd_reg(&H00) Call Lcd_reg(&H0c) Elseif L = "I" Then Call Lcd_reg(&H00) Call Lcd_reg(&H0d) Elseif L = "J" Then Call Lcd_reg(&H00) Call Lcd_reg(&H0e) Elseif L = "K" Then Call Lcd_reg(&H10) Call Lcd_reg(&H00) Elseif L = "L" Then Call Lcd_reg(&H01) Call Lcd_reg(&H04) Elseif L = "M" Then Call Lcd_reg(&H01) Call Lcd_reg(&H08) Elseif L = "N" Then Call Lcd_reg(&H01) Call Lcd_reg(&H0c) Elseif L = "O" Then Call Lcd_reg(&H00) Call Lcd_reg(&H02) For H = 1 To 40 Call Lcd_reg(&H01) Call Lcd_reg(&H04) Next H End If F = 0 End If End If Next E I2cstop End Sub ' Subroutine to send a function to the LCD-display Sub Lcd_reg(r As Integer) I2cwbyte R Reset R.rs Set R.e1 Reset R.e2 I2cwbyte R Reset R.rs Reset R.e1 Reset R.e2 I2cwbyte R End Sub ' Subroutine to send a character to the LCD-display Sub Lcd_char(g As Integer) D = G G = G And &B11110000 Rotate G , Right , 4 I2cwbyte G Reset G.rs Set G.e1 Reset G.e2 I2cwbyte G Reset G.rs Reset G.e1 Reset G.e2 I2cwbyte G G = D G = G And &B00001111 I2cwbyte G Reset G.rs Set G.e1 Reset G.e2 I2cwbyte G Reset G.rs Reset G.e1 Reset G.e2 I2cwbyte G End Sub Sub Lcd_init1() ___lcdno = 0 Initlcd Cls Home Cursor Off Noblink ___lcdno = 1 Initlcd Cls Home Cursor Off Noblink ___lcdno = 0 End Sub End