The LCD module has the characteristics of small size, low power consumption, rich display content, and so on. The LCD module is now the most commonly used information display device in Single Chip Microcomputer Application Design. This experiment uses the common 1602b serial LCD module as an example to describe the simple use of this module. 1602b can display 2 lines of 16 characters, there are 8-Bit Data Bus D0-D7, and RS, R/W, en three control ports, the operating voltage is 5 V, it also has character contrast adjustment and backlight. The module can also be transmitted twice as a four-bit data with only a D4-D7. This saves mcu I/O port resources. In this experiment, "Welcome www.527dz.com!" is displayed cyclically in bits and four bits of data are used !" And "Tel: 13308844201 527dz@527dz.com ". Shows the appearance of 1602b: 1602b package size diagram: 1602b pin description:
No. |
Symbol |
Pin description |
No. |
Symbol |
Pin description |
1 |
VSS |
Power supply location |
9 |
D2 |
Bidirectional data port |
2 |
VDD |
Power Supply Cathode |
10 |
D3 |
Bidirectional data port |
3 |
Vl |
Contrast Adjustment |
11 |
D4 |
Bidirectional data port |
4 |
RS |
Data/command Selection |
12 |
D5 |
Bidirectional data port |
5 |
R/W |
Read/write Selection |
13 |
D6 |
Bidirectional data port |
6 |
E |
Module enable |
14 |
D7 |
Bidirectional data port |
7 |
D0 |
Bidirectional data port |
15 |
BLK |
Backlight location |
8 |
D1 |
Bidirectional data port |
16 |
Bla |
Backlight Cathode |
Note: from the front of the module, the pins are arranged from the right to the left: 15 feet, 16 feet, and then 1-14 feet (marked on the circuit board ).
VDD: positive power supply, 4.5-5.5 V, usually using 5 V voltage;
Vl: LCD contrast regulator. The voltage adjustment range is 0-5 V. The contrast is the weakest when the main power supply is connected, and the contrast is the highest when the ground power supply is connected. However, when the contrast is too high, a "ghosting" is generated. Therefore, a 10 k potentiometer is usually used to adjust the contrast, or directly concatenate a resistor to the ground;
RS: MCU writes data or command selection end. When the MCU needs to write commands, the RS is set to a low level; when the MCU wants to write data, the RS is set to a high level;
R/W: read/write controller. R/W reads data when the power is high, and R/W reads data when the power is low;
E: LCD module enables signal control. When writing data, you need to drop along the trigger module.
D0-D7: 8-Bit Data Bus, three-state bidirectional. If mcu I/O port resources are insufficient, the module can also use only 4-bit data cable D4-D7 interface to transmit data. The charger adopts the four-digit data transmission mode;
Bla: LED Backlight positive pole. When backlight is required, BLA concatenates a throttling resistor to VDD and BLK is grounded. The backlight current of this module is measured to be about 50mA;
BLK: LED backlights.
Route diagram: C source code download: Click here to download 1602b Data Manual:
Click here to download (PDF)
Click here to download (for more detailed HTML instructions, thank you for providing xsykg)
Postscript:
Andy provided a six-line connection method, that is, LCD _rw grounding (W is used in RW and R is not required, so a line can be saved ). Click here to download 6-line source code
Afeng provided the circuit and C code for M16: Click here to download the M16 circuit diagram (Protel format) and source code
According to the report of rz12345, the downloaded 1602 six-wire driver was used and the atmanavr driver was used to compile the driver. After the download test, it was found that the driver was unstable, and the result was that the 1602 driver sometimes failed to work normally when switching the power supply, check the usage instructions and find that the original program initialization for 1602 is insufficient. The test changes are as follows:
Void LCD _init (void) { Delay_nms (1000 ); Unsigned int I = 0; For (I = 0; I <20; I ++) { LCD _write_char (0, 0x28); // 4bit Test Delay_nms (15 ); } LCD _write_char (0, 0x0c); // display on Delay_nms (5 ); .............................
|