Driving An LCD Via The Sixteen From Four' Port Expansion Circuit
Driving An LCD Via The Sixteen From Four' Port Expansion Circuit
Introduction
The library assumes that the R/W pin on the LCD module is tied to ground, as it is on the
printed circuit board for the project. It is therefore omitted from the descriptions that
follow.
Before a command can be sent to the LCD it is necessary to ensure that RS has been set
low: it is this that tells the LCD that the next byte constitutes a command.
Key:
1: high logic level
0: low logic level
X: don’t care
RS D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 0 0 0 0 1
Home cursor
This command returns the cursor to the home position. If the display has been shifted,
the shift offset is also reset.
RS D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 0 0 0 1 x
RS D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 0 0 1 C S
RS D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 0 1 P C B
Cursor functions
This command determines whether the cursor moves or whether the display shifts when
a character is written, and in which direction.
M = 0: Cursor moves
M = 1: Display shifts
S = 0: Shift to the left
S = 1: Shift to the right
RS D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 1 M S x x
Display settings
This command determines (among other things) whether communication with the LCD is
carried out in four-bit mode or in eight-bit mode.
B = 0: Four-bit mode
B = 1: Eight-bit mode
N = 0: One line
N = 1: Two lines
F = 0: 5 × 7 pixel characters
F = 1: 5 × 10 pixel characters
RS D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 1 B N F x x
RS D7 D6 D5 D4 D3 D2 D1 D0
0 0 1 A5 A4 A3 A2 A1 A0
RS D7 D6 D5 D4 D3 D2 D1 D0
0 1 A6 A5 A4 A3 A2 A1 A0
Write to memory
The given data will be written to the most recently selected area of memory.
RS D7 D6 D5 D4 D3 D2 D1 D0
1 D7 D6 D5 D4 D3 D2 D1 D0