Hello everyone,
I'de like to share this project, may come handy for hobbyist working around LCD display.
My search for a serial LCD that can receive serial data from 300 to 19200 baud on the internet was not successful
then I roll-up my sleeves and build this LCD backpack that use a common Hitachi HD44780 display. (still popular today)
My project was simple with parts already on hand like PIC16F690, NPN smd transistor, potentiometer, resistor. and PBP3 Basic code.
So enjoy,
Code:
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Name : 16F690 LCD BACKPACK
' Date : Sep 27-2025
' Note : 393 words used of 2048
' Notes : Serin2 Baud Rate 300 ~ 19200 Intrc_OSC 8Mhz
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#CONFIG
cfg = _INTRC_OSC_NOCLKOUT
cfg&= _WDT_OFF
cfg&= _PWRTE_OFF
cfg&= _MCLRE_OFF
cfg&= _CP_OFF
cfg&= _CPD_OFF
cfg&= _BOD_OFF
cfg&= _IESO_OFF
cfg&= _FCMEN_OFF
__CONFIG cfg
#ENDCONFIG
DEFINE OSC 8 ' Core is running at EXT-CRYSTAL 16MHz PBP 33,217
ANSEL = 0 ' Set all pins digital
ANSELH = 0 ' Set all pins digital
OPTION_REG.7 = 0 ' PORTA/PORTB pull-ups are enabled by individual port latch values
CM1CON0 = 0 ' Analog comparators off
En var Portb.4 : low en
RS var Portb.6 : low rs
B1 var byte : b1 = 0
' 300=3313 600=1646 1200=813 2400=396 4800=188 9600=84 19200=32
BaudR var byte : baudr = 32
TRISA = 0 : TRISB = 100000 : TRISC = 0
PORTA = 0 : PORTB = 0 : PORTC = 0
OSCCON = $70
high Porta.0 ' Backlight ON
gosub LCDinit ' initialise LCD
'Serin2
main:
serin2 Portb.5,baudr,3,main,[b1]
if b1 < 253 then ' Characters
PORTC = b1
HIGH EN : PAUSEus 5 : LOW EN
goto main
elseif b1 = 254 then ' LCD Command
low RS
serin2 Portb.5,baudr,3,main,[b1]
PORTC = b1 ' output the data
HIGH EN : PAUSEus 5 : LOW EN
high RS ' character mode
goto main
elseif b1 = 255 then
low rs ' LCD Command
serin2 Portb.5,baudr,3,main,[b1]
if b1 = 0 then
low porta.0 ' Back Light OFF
high rs
endif
if b1 = 8 then
high porta.0 ' Back Light ON
high rs
endif
goto main ' loop back to top
ENDIF
LCDINIT: ' Standard LCD Module Initialisation
PORTC = 000001 ' 2, Clear Display
HIGH EN : PAUSEus 300 : LOW EN ' Send data
pause 4
PORTC = 000010 ' 4, Return Home
HIGH EN : PAUSEus 300 : LOW EN
pause 4
PORTC = 111000 ' 1, 8 bit, 2 line, 5x8 Characters
HIGH EN : PAUSEus 300 : LOW EN
pause 4
' PORTC = 001100 ' Display on, no cursor, no blink
PORTC = 001110 ' 1, Display on, cursor, blink
HIGH EN : PAUSEus 300 : LOW EN
pause 4
PORTC = 000110 ' 1, Entry mode
HIGH EN : PAUSEus 300 : LOW EN
pause 4
high rs ' character mode
RETURN

Bookmarks