4.1 Introduction to LCD
4.1.1 LCD1602 Overview
Although the previous part of the digital tube is simple to drive, but the 1-bit digital tube can only display 1 number, and it is difficult to display letters, in order to solve this problem, the introduction of the LCD module.
LCD (Liquid Crystal Display), at the end of the 19th century, Austrian botanists discovered liquid crystals, that is, liquid crystals, which means that a substance has both the fluidity of a liquid and some arrangement characteristics similar to a crystal. Under the action of electric field, the arrangement of liquid crystal molecules will change, thus affecting its optical properties, a phenomenon called electro-optical effect. Using the electro-optical effect of liquid crystals, British scientists manufactured the first liquid crystal display, LCD, in the last century.
We commonly used LCD is generally LCD1602 and LCD12864, which LCD1602 is also known as character LCD, because LCD1602 can only display 16 × 2 ASCII code (common 0 ~ 9, A ~ Z, a ~ z, and some punctuation marks), and LCD12864 is known as dot matrix LCD, the difference between the two is LCD1602 can not display Chinese, but LCD12864 due to the internal structure of the reason, it is possible to display Chinese and pictures, the two modules are set up in a similar way, here LCD1602 LCD as an example to explain the way to use.
4.1.2 LCD1602 pin description
4.1.3 Operation Timing
(1) Write Operation Timing
(2) Read operation timing
4.1.4 LCD1602 internal registers
(1) Clear screen register
(2) Display control register
DB2: Display switch
0: off
1: On
DB1: Cursor switch
0: off
1:Display
DB0: Cursor blinking switch
0:No blinking
1: Blinking
(3) Function setting register
DB4: Data bus width
0: 4 bits
1: 8 bits
DB3: Display the number of rows
0: Display 1 line
1: Display 2 lines
DB2: Occupied dot matrix size
0:Each character occupies 5×7 dot matrix
1: Each character occupies 5×10 dot matrix
(4) Mode setting register
DB1: Cursor movement direction
0: Cursor move left
1: Cursor move right
DB0: Display movement switch
0: The display does not move after writing data
1: The whole display moves to the right after writing data
4.2 Routine Analysis
4.2.1 Principle diagram
4.2.2 Source Code
Note: LCD1602 two lines of address are 0x80 and 0xC0, LCD write data must first write the address, then write the data, 89 lines inside the ‘A’ on behalf of the ASCII code value written A.