LCD use in many device to display message, like in printer, coffee machine, remote etc.There are a lot of type  LCD present in market, these are may be alphanumeric, graphical or any other type. Here I will discuss about the alphanumeric LCD.

Alphanumeric LCD comes in different size 8*1, 8*2, 16*1, 16*2 or 20*4 etc. These LCD only able to display characters, who have the ASCII value. Some alphanumeric LCD provide the facility to generate own custom characters.

In this article I will describe the steps to display moving message on 16*2 alphanumeric LCD, but before it I want to discuss about its pin configuration and connection.

Pin configuration of 16*2 alphanumeric LCD

lcd pins

Pin  Description of Pin
1. VSS (Ground Pin).
2. VCC (+3.3 to +5V).
3. VEE (Use to adjust the contrast).
4. RS (Resistor select pin).

RS = 0; select command resistor.

RS = 1; select data resistor.

5. R/W (Read and Write Pin)

R/W = 0; write operation.

R/W = 1; Read operation.

6. E (clock enable pin).
7. D0  (I/O)
8. D1  (I/O)
9. D2  (I/O)
10. D3  (I/O)
11. D4  (I/O)
12. D5  (I/O)
13. D6  (I/O)
14. D7  (I/O)
15. Led  (+ve).
16. Led  (-ve).

Note: Interface of HD44780 supports two modes operation, 8 bit mode and 4 bit mode.In this article I will only discuss about the 8 bit mode.

Some useful commands for LCD

Command  Description
0x01 To clear LCD.
0x0e Display on and cursor blink.
0x0c Display on and cursor off.
0x38 8 bit mode and 2 line 5*8 matrix.
0x06 Increment cursor (shift toward right)
0x04 Decrement cursor (shift toward left)
0x80 Cursor in beginning of first line.
0xc0 Cursor in beginning of second line.

Steps to write display message on LCD

  • Initialize the LCD using the LCD initialization commands.
  • Set the address of DDRAM ,where you want to display the character.
  • Write the character on the data bus of LCD.
When we pass command or data on LCD then follow following steps.
  • If passing the command then make RS pin low (RS = 0) either for data make RS pin high (RS = 1).
  • Set Enable pin high (EN = 1).
  • Write the command or data on data bus.
  • Set Enable pin low (EN = 0).

Source code to display moving message on 16×2 alphanumeric LCD.

moving message on lcd