Mr Robert

Here is some code I used for a 4X40 display (the reason for E1 and E2). It may give you an idea how to send data to the LCD from the PC. I assume you have a program that can be written to send and receive data via the serial port in your PC.

Code:
' PicBasic program to demonstrate operation of an LCD in 4-bit mode
' LCD DMC40457 W/backlight 16F876
' LCD should be connected as follows:
'  PIN--LCD     PIC                             4016
'  4    DB4     PortB.4
'  3    DB5     PortB.5
'  2    DB6     PortB.6
'  1    DB7     PortB.7
'  11   RS      PortB.0
'       E       PortB.1                         pin 8 & 11
'  10   RW      Ground
'  14   Vdd     5 volts
'  13   Vss     Ground
'  12   Vo      10K potentiometer (or ground)
'       DB0-3   No connect
'   9   E1      To enable logic ckt             pin 9
'   15  E2      as above                        pin 10
'Backlight controled via a NPN transistor with 1K resistor from porta.2 to base.
' E1 & E2 controlled via a bilaterial switch 4016
'               portc.4                         pin 6
'               portc.5                         pin 12
'*********************************************************************************

DEFINE LOADER_UESD 1    'Enable bootloader
DEFINE OSC 20           ' 20Mhz Xtl
DEFINE HSER_RCSTA 90h   'Set up USART
DEFINE HSER_TXSTA 24h
DEFINE HSER_BAUD 9600


DEFINE LCD_DREG PORTB       'Set up LCD  Data Portb
DEFINE LCD_DBIT 4           ' bit 4 - 8 data bus
DEFINE LCD_RSREG PORTB      'RS portb.0
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTB       'E portb.1
DEFINE LCD_EBIT 1
DEFINE LCD_BITS 4           '4 data bits
DEFINE LCD_LINES 2          '2 lines
DEFINE LCD_COMMANDUS 2000   
DEFINE LCD_DATAUS 50
ADCON1 = 7              'Make porta all digital
trisa = %00000000       'Make porta all outputs
output portc.4      ' E1 to 4016
output portc.5      ' E2 to 4016


RCIF    VAR     PIR1.5          ' Alias RCIF (USART Receive Interrupt Flag)
OERR    VAR     RCSTA.1         ' Alias OERR (USART Overrun Error Flag)
CREN    VAR     RCSTA.4         ' Alias CREN (USART Continuous Receive Enable)

buffer_size     CON     32              ' Sets the size of the ring buffer
buffer          VAR     BYTE[buffer_size]       ' Array variable for holding received characters
index_in        VAR     BYTE    ' Pointer - next empty location in buffer
index_out       VAR     BYTE    ' Pointer - location of oldest character in buffer
bufchar         VAR     BYTE            ' Stores the character retrieved from the buffer
bufchar1        VAR     BYTE
i               VAR     BYTE            ' loop counter
col             VAR     BYTE            ' Stores location on LCD for text wrapping
errflag         VAR     BYTE            ' Holds error flags
A               VAR     BYTE
E1              VAR     portc.4     'E1 control to 4016
E2              VAR     portc.5     'E2 control to 4016

index_in = 0                    'Initalize varialbles
index_out = 0
i = 0
col = 1
low porta.2                     'turn off backlight
errflag = 0                     ' Reset the error flag
INTCON = %11000000              ' Enable interrupts
On INTERRUPT GoTo serialin      ' Declare interrupt handler routine
PIE1 .5 = 1                     ' Enable interrupt on USART
high E1                         ' Enable E1  
High E2                         ' Enable E2

        
        
       
Pause 500                       ' Wait for LCD to startup

START:
    GOSUB OPENING                'Staart lcd display indication
    Lcdout $fe, 1               'clear LCD
    low E2                      ' Disable E2 turn off second half of display
    GOTO LOOP
LOOP:

    

display:                                ' dump the buffer to the LCD

    IF errflag Then error   ' Handle error if needed
    If index_in = index_out Then Loop       ' loop if nothing in buffer

    GoSub getbuf    ' Get a character from buffer
    'IF bufchar = 253 THEN CONT  'if control character is detected go to control
    LCDOut bufchar  ' Send the character to LCD
                

GoTo display                    ' Check for more characters in buffer



' Subroutines

Disable                                 ' Don't check for interrupts in this section

getbuf:                                 ' move the next character in buffer to bufchar
        index_out = (index_out + 1)                     ' Increment index_out pointer (0 to 63)
        If index_out > (buffer_size - 1) Then index_out = 0     ' Reset pointer if outside of buffer
        bufchar = buffer[index_out]                     ' Read buffer location
        IF bufchar = 253 THEN CONT  'if control character is detected go to control
Return

error:                                  ' Display error message if buffer has overrun
        IF errflag.1 Then       ' Determine the error
                LCDOut $FE,$c0,"Buffer Overrun" ' Display buffer error on line-2
        Else
                LCDOut $FE,$c0,"USART Overrun"  ' Display usart error on line-2
        EndIf
        
        LCDOut $fe,2            ' Send the LCD cursor back to line-1 home
        For i = 2 To col        ' Loop for each column beyond 1
                LCDOut $fe,$14  ' Move the cursor right to the right column
        Next i
        
        errflag = 0                     ' Reset the error flag
        CREN = 0                        ' Disable continuous receive to clear overrun flag
        CREN = 1                        ' Enable continuous receive

        GoTo display            ' Carry on
        
        
' Interrupt handler

serialin:       ' Buffer the character received
        If OERR Then usart_error                        ' Check for USART errors
        index_in = (index_in + 1)                       ' Increment index_in pointer (0 to 63)
        If index_in > (buffer_size - 1) Then index_in = 0 'Reset pointer if outside of buffer
        If index_in = index_out Then buffer_error       ' Check for buffer overrun
        HSerin [buffer[index_in]]                       ' Read USART and store character to next empty location
        If RCIF Then serialin                           ' Check for another character while we're here
        
Resume            ' Return to program

buffer_error:
        errflag.1 = 1         ' Set the error flag for software
' Move pointer back to avoid corrupting the buffer. MIN insures that it ends up within the buffer.
        index_in = (index_in - 1) MIN (buffer_size - 1)
        HSerin [buffer[index_in]]       ' Overwrite the last character stored (resets the interrupt flag)
usart_error:
        errflag.0 = 1          ' Set the error flag for hardware
        
Resume                                  ' Return to program



cont:
    
    index_out = (index_out + 1)                     ' Increment index_out pointer (0 to 63)
    If index_out > (buffer_size - 1) Then index_out = 0     ' Reset pointer if outside of buffer
    bufchar = buffer[index_out]                     ' Read buffer location
    if bufchar = "A" then E1_          ' enable 1st half of display
    if bufchar = "C" then E2_           'enable 2nd half of display
    if bufchar = "B" then BL_On         'backlight on
    if bufchar = "F" then BL_Off        'backlight off
    
    goto display


E1_:
high E1
Low E2
PAUSE 50
Lcdout $fe, 2
goto display

E2_
low E1
High E2
Pause 50
Lcdout $fe, 2
goto display

BL_On:
    high porta.2
goto display

BL_Off:
    low porta.2
goto display


OPENING:
     FOR A = 1 TO 2
        Lcdout $fe, 1   ' Clear LCD screen
        Lcdout "LCD"  ' Display Hello
  
        Pause 500       ' Wait .5 second
        'enable debug
        
        Lcdout $fe, 1   ' Clear LCD screen
        Lcdout $FE, $C0
        Lcdout "ACTIVE"
  
        Pause 500       ' Wait .5 second
        'enable debug

    NEXT A
    
    RETURN
    
end