PICAXE 08M2 via I2C PCF8574 8-Bit I/O Port Expander driving a 20x4 LCD
This is a DEMO of a PICAXE 08M2 using a PCF8574 I2C 8-Bit I/O Port Expander driving a standard 20x4 Blue LCD display.
This code is part of a library that will be used for a future build of a QRSS transmitter. The transmitter frequency will be created from a SI5351 I2C configurable clock generator.
The small device in front of the blue LCD is a 128x64 OLED I2C 0.96 inch white display. Uses a SSD1315 controller chip.
Photos
Photo is for illustrative purposes only. Please refer to the description.
Code Sample
To copy code: Hover over the right top corner of the code panel. Click COPY button, the code will be COPIED to the clipboard.
' /*****************************************************************/
' /* PICAXE 08M2+ via I2C PCF8574 Port Expander driving a 20x4 LCD */
' /* DEMO Edit Code - rhb.20230717 */
' /* Jewel of the PICAXE code min ed from the Forum */
'/*****************************************************************/
#PICAXE 08M2
Symbol LCD_ADDR = $4E
Symbol bitRS = bit8
Symbol bitWR = bit9
Symbol bitE = bit10
Symbol bitBKL = bit11
Symbol bitD 4 = bit12
Symbol bitD5 = bit13
Symbol bitD6 = bit14
Symbol bitD7 = bit15
Symbol i = b27
Symbol j = b26
#DEFINE LOGO "radioSPARKS VE3XRM"
#DEFINE MESSAGE_0 "*VFO A 10.138.70 USB"
#DEFINE MESSAGE_1 " VFO B 21.094.60 U SB"
#DEFINE MESSAGE_2 " MC 31 7.038.70 USB"
#MACRO PRINT( string )
j = 0
do
lookup j, ( string, 0 ), b0
if b0 <> 0 then
Gosub SendB0AsDataByte
end if
j = j + 1
loop until b0 = 0
#ENDMACRO
INIT_DISPLAY:
HI2CSetup I2CMA STER, LCD_ADDR, I2CFAST, I2CBYTE
b0 = $33 : Gosub SendB0AsInitByte
b0 = $33 : Gosub SendB0AsInitByte
b0 = $32 : Gosub SendB0AsInitByte
b0 = $28 : Gosub SendB0AsCommandByte
b0 = $0C : Gosub SendB0AsCommandByte
b0 = $06 : Gosub SendB0As CommandByte
b0 = $01 : Gosub SendB0AsCommandByte
Pause 2
MAIN:
; LINE ONE
b0 = $80 : Gosub SendB0AsCommandByte ; %1000 0000
PRINT(LOGO)
; LINE TWO
b0 = $C0 : Gosub SendB0AsCommandByte ; %1100 0000
PRINT(MESSAGE_0)
; LINE THREE
b0 = $94 : Gosub SendB0AsCommandByte ; %1001 0100
PRINT(MESSAGE_1)
; LINE FOUR
b0 = $D4 : Gosub SendB0AsCommandByte ; %1101 0100
PRINT(MESSAGE_2)
Do : Loop
SendB0AsInitByte:
Pause 15
bitWR = 0 ; Keep WR signal low
bitBKL = 1
SendB0AsCommandByte:
bitRS = 0 ; Send byte as a command
SendB0AsDataByte:
bitD4 = bit4 ; Send msb first
bitD5 = bit5
bitD6 = bit6
bitD7 = bit7
bitE = 1
b2 = b1 ; b 2 holds msb with E set
bitE = 0 ; b1 holds msb with E clear
HI2cOut b1, ( b2, b1 )
bitD4 = bit0 ; Send lsb second
bitD5 = bit1
bitD6 = bit2
bitD7 = bit3
bitE = 1
b2 = b1 ; b2 holds lsb with E set
bitE = 0 ; b1 holds lsb with E clear
HI2cOut b1, ( b2, b1 )
bitRS = 1 ; Send data byte next time
Return
'/* EOF */