Using connection mode 12:
The LCD is controlled via I2C. A type 12 is the Ywmjkdz I2C adapter with potentiometer variable resistor) bent over top of chip. To use mode 12 you must define the I2C ports as normal in your GCB code. Then, define the LCD type, set the I2C_address of the LCD adapter and the LCD speed, if required.
Relevant Constants:
These constants are used to control settings for the Liquid Crystal
Display routines included with GCBASIC. To set them, place a line in the
main program file that uses #define to assign a value to the particular
constant.
When using 2-bit mode only three constants must be set - all others can be ignored.
| Constant Name | Controls | Value |
|---|---|---|
|
|
I/O mode |
|
|
|
Address of I2C adapter |
Default |
|
|
Address of a second I2C adapter, for multiple-adapter use |
Not set |
|
|
Address of a third I2C adapter, for multiple-adapter use |
Not set |
|
|
Address of a fourth I2C adapter, for multiple-adapter use |
Not set |
To set the correct address see the picture below:
Example:
#chip 16F877A, 20
' Connection mode 12: I2C via a Ywmjkdz-layout adapter (the variant with
' the contrast potentiometer bent over the top of the chip).
#define I2C_MODE Master
#define I2C_DATA PORTC.4
#define I2C_CLOCK PORTC.5
#define LCD_IO 12
#define LCD_I2C_Address_1 0x4E ' <<< the I2C address this page's constant table documents
CLS
Print "Hello World."Key line: #define LCD_I2C_Address_1 0x4E — sets the I2C address of the adapter this page documents; see Multiple I2C Adapters (LCD_IO 12) for driving up to four of these adapters on the same bus.
For further code examples see I2C LCD Solutions.
See the separate sections of the Help file for the specifics of each Connection Mode.
See Also:
- LCD_IO 0 — single subroutine, software-driven mode
- LCD_IO 1 — 1-wire, via a 74HC595 shift register
- LCD_IO 2 — 2-wire shift register, deprecated
- LCD_IO 2_74xx164 — 2-wire via 74HC164/74LS164, the preferred 2-wire method
- LCD_IO 2_74xx174 — 2-wire via 74LS174, deprecated
- LCD_IO 3 — 3-wire shift register with an added Enable line
- LCD_IO 4 — 4-bit parallel connection
- LCD_IO 8 — 8-bit parallel connection
- LCD_IO 10 — I2C via a PCF8574/PCF8574A I/O expander
- LCD_IO 14 — SPI expander
- LCD_IO 16 — PIC16LF72 SPI expander
- LCD_IO 107 — K107 serial adapter

