16x2 character LCD (HD44780)
The 16 by 2 character LCD, HD44780 style: sixteen pins, and a green or blue window with two rows of sixteen characters behind it.
Unlike the graphic panels, it has no framebuffer. A sketch sends it characters,
and the controller has the shapes in its own ROM. RS says whether a byte is a
command or a character, RW says which way data goes (tie it to ground; nothing
here answers a read), and E is the clock, latching the bus on its falling edge.
The four-row version on the same controller and the same pins is the 20x4.
Pins
| Pin | What it does |
|---|---|
VSS |
Ground. |
VDD |
Supply. |
V0 |
Contrast; near VSS the characters are darkest. |
RS |
Low for a command, high for a character. |
RW |
Read/write; tie to ground. |
E |
Clock, latches on the falling edge. |
D0–D7 |
The data bus, 8-bit or 4-bit wide. |
A, K |
The backlight LED. |
Properties
None. Behavior comes entirely from the command stream.
What the model gets right
At power-on the interface is eight bits wide; a function-set command can switch it
to four, after which every byte is two writes on D4–D7, high nibble first.
Both widths work, because the model is the state machine and not a special case for
either. Busy is modeled too: a write takes 37 microseconds and a clear takes
1.52 ms, and a byte clocked in while the controller is still busy is dropped,
exactly as it is on the bench, the bug behind nearly every "my LCD prints rubbish"
question. V0 sets the contrast realistically: at VDD the characters vanish, and
left unwired it is taken as VSS, the way the cheap modules with a fixed resistor
behave. A/K light when A is at least two volts above K, and with neither
driven the module's own backlight jumper is taken as fitted.
What it does not model
No reads of any kind: the busy flag, the address counter and DDRAM all read back nothing. No 5x10 font mode, no bias, temperature or viewing-angle effects.
The busy times are the datasheet's two typical figures used as exact values: 37
microseconds for a write and 1.52 milliseconds for clear and home. A real HD44780's
timing follows whatever its internal oscillator is doing, so those move by tens of
percent between parts and with temperature. Nothing checks the E pulse width or the
data setup and hold time either, so a driver can clock the bus as fast as it likes and
a real module would not keep up.
Dropping a byte that arrives while the controller is busy is this model's choice, made
so the fault is visible and repeatable. On a real part the outcome is undefined and
more often a corrupted character than a lost one. The backlight is on or off (A at
least 2 V above K) with no brightness and no current.
Common mistakes
Writing faster than the busy time allows. firmware/lib/mokxi_lcd1602.h waits
50 microseconds after a byte and 2 ms after a clear for exactly this reason; a
custom driver that skips the wait drops bytes here the same way a real chip would.
See it in action
Thermometer prints a live TMP36 reading to this display. Open it at /templates.