Here's a shrink down version for displaying messages from internal arrays no serial input involved.
practical if just an operating device with control buttons attach to the remaining 5 ports is needed
Code:'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Project : LCD Backpack Self Text (Write text on LCD no serial port) ' Name : 16F690 LCD BACKPACK for Hitachi HD44780 1601 / 1602 / 2004 ' Date : Oct 3 2025 ' Notes : 320 words used of 4096 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Device = 16F690 'Declare Xtal = 8 'Config INTRC_OSC_NOCLKOUT, WDT_OFF, PWRTE_OFF, MCLRE_OFF, CP_OFF, CPD_OFF, IESO_OFF, FCMEN_OFF Declare Xtal = 20 Config HS_OSC, WDT_OFF, PWRTE_OFF, MCLRE_OFF, CP_OFF, CPD_OFF, IESO_OFF, FCMEN_OFF ANSEL = 0 ' Set all pins digital ANSELH = 0 ' Set all pins digital TRISA = 0 : TRISB = %00100000 : TRISC = 0 : PORTA = 0 : PORTB = 0 : PORTC = 0 OSCCON = $70 Dim I As Byte ' 1601 1602 16 Char 1/2 Lines Dim MyArrayA[16] As Byte = "0123456789ABCDEF" Dim MyArrayB[16] As Byte = "abcdefghijklmnop" ' 2004 20 Char 4 Lines 'Dim MyArrayC[20] As Byte = "ABCDDE1234567890ABCD" 'Dim MyArrayD[20] As Byte = "abcdefghijklmnop1234" 'Dim MyArrayE[20] As Byte = "ABCDDE1234567890abcd" 'Dim MyArrayF[20] As Byte = "abcdefghijklmnop1234" GoSub LCDINIT ' initialise LCD PORTA = 1 ' Backlight ON main: ' 1601 / 1602 PORTB = 0 : PORTC = 128 : PORTB = %00010000 : DelayUS 1 : PORTB = 0 : PORTB = %01000000 : DelayMS 3 ' Line 1 For I = 0 To 15 PORTC = MyArrayA[I] : PORTB = %01010000 : DelayUS 1 : PORTB = %01000000 : DelayMS 1 Next I PORTB = 0 : PORTC = 192 : PORTB = %00010000 : DelayUS 1 : PORTB = 0 : PORTB = %01000000 : DelayMS 3 ' Line 2 For I = 0 To 15 PORTC = MyArrayB[I] : PORTB = %01010000 : DelayUS 1 : PORTB = %01000000 : DelayMS 1 Next I ' 2004 (*PORTB = 0 : PORTC = 128 : PORTB = %00010000 : DelayUS 1 : PORTB = 0 : PORTB = %01000000 : DelayMS 3 ' Line 1 For I = 0 To 19 PORTC = MyArrayC[I] : PORTB = %01010000 : DelayUS 1 : PORTB = %01000000 : DelayMS 1 Next I PORTB = 0 : PORTC = 192 : PORTB = %00010000 : DelayUS 1 : PORTB = 0 : PORTB = %01000000 : DelayMS 3 ' Line 2 For I = 0 To 19 PORTC = MyArrayD[I] : PORTB = %01010000 : DelayUS 1 : PORTB = %01000000 : DelayMS 1 Next I PORTB = 0 : PORTC = 148 : PORTB = %00010000 : DelayUS 1 : PORTB = 0 : PORTB = %01000000 : DelayMS 3 ' Line 3 For I = 0 To 19 PORTC = MyArrayE[I] : PORTB = %01010000 : DelayUS 1 : PORTB = %01000000 : DelayMS 1 Next I PORTB = 0 : PORTC = 212 : PORTB = %00010000 : DelayUS 1 : PORTB = 0 : PORTB = %01000000 : DelayMS 3 ' Line 4 For I = 0 To 19 PORTC = MyArrayF[I] : PORTB = %01010000 : DelayUS 1 : PORTB = %01000000 : DelayMS 1 Next I*) DelayMS 2000 PORTB = 0 : PORTC = 1 : PORTB = %00010000 : DelayUS 1 : PORTB = 0 : PORTB = %01000000 : DelayMS 4 ' Clear display DelayMS 255 PORTA = 0 ' Bacck Light off DelayMS 255 PORTA = %00000001 ' Bacck Light on DelayMS 255 GoTo main LCDINIT: PORTC = %00000001 : PORTB = %00010000 : DelayUS 1 : PORTB = 0 : DelayMS 4 ' Clear display PORTC = %00000010 : PORTB = %00010000 : DelayUS 1 : PORTB = 0 : DelayMS 2 ' Return Home PORTC = %00111000 : PORTB = %00010000 : DelayUS 1 : PORTB = 0 : DelayMS 2 ' 5x8 Character 8 Bit, 2 Line PORTC = %00001100 : PORTB = %00010000 : DelayUS 1 : PORTB = 0 : DelayMS 2 ' %00001DCB Display on/off, cursor on/off, blink y/n PORTC = %00000110 : PORTB = %00010000 : DelayUS 1 : PORTB = 0 : DelayMS 2 ' Entry mode Return


Reply With Quote

Bookmarks