Liquid crystal is a polymer material. The main principle of liquid crystal display is that electric current stimulates liquid crystal molecules to produce points, lines, and surfaces and cooperates with the back light tube to form a picture. For the sake of simplicity, all kinds of liquid crystal displays are directly called liquid crystal. Various types of liquid crystals are usually named according to the number of rows of displayed characters or the number of rows and columns of liquid crystal dot matrix. For example: 1602 means that 16 characters are displayed per line, and a total of two lines are displayed; similar names include 0801, 0802, 1601, etc. This type of liquid crystal is usually a character liquid crystal, that is, it can only display ASCII code characters, such as numbers, uppercase and lowercase letters, various symbols, etc. 12232 liquid crystal belongs to graphic liquid crystal, which means that the liquid crystal consists of 122 columns and 32 rows. Liquid crystal is small in size, low in power consumption, and simple in display operation, but it has a fatal weakness, and its operating temperature range is very narrow.
Reference address:51 MCU-LCD 1602
Initial setup:
RAM address map:
Write operation timing:
To achieve two-line display, slide from left to right.
#include
#define uchar unsigned char
#define uint unsigned int
sbit RS = P1^0;
sbit RW = P1^1;
sbit E = P1^2;
uint i;
uchar code table[] = "I LOVE MCU!";
uchar code table1[]="WWW.TXMCU.COM";
void delay(uint t){
int i,j;
for(i = 0; i < t; i++)
for(j = 200; j > 0; j--)
;
}
void lcd_com(uchar s){
RS = 0; //Low level, write instruction
P2 = s; //Transfer data
delay(14); //Look at the timing diagram, the data needs to be stable for a while
E = 1; //Give a high pulse to send a command
delay(14); //As shown in the figure, the high pulse is delayed for a period of time to ensure that the command is sent
E = 0; //Send is finished, E is set to low level
}
void lcd_data(uchar s){
RS = 1;
P2 = s;
delay(14);
E = 1;
delay(14);
E = 0;
}
void init(){
RS = 1; //First send command, at the initial moment RS is high, E and RW are low
E = 0;
RW = 0;
lcd_com(0x38); //Set to 16*2 display, 5*7 dot matrix, 8-bit data interface
lcd_com(0x0f); //Turn on the display, display the cursor, and the cursor flashes
lcd_com(0x06); //Address pointer plus one after reading or writing a character
lcd_com(0x01);
lcd_com(0x80+0x10); //The display screen corresponds to a RAM, and there is another RAM outside the screen
for(i = 0; i < 11; i++){ //Set the address to the off-screen RAM to achieve the scrolling effect
RS = 0;
lcd_data(table[ i]);
delay(40);
}
lcd_com(0x80+0x50);
for(i = 0; i < 13; i++){
RS = 0;
lcd_data(table1[ i]);
delay(40);
}
for(i = 0; i < 13; i++){
lcd_com(0x18); //0x18, move the display to the left, and the cursor moves with it
delay(200);
}
}
void main(){
init();
while(1);
}
Previous article:51 MCU-Serial Port
Next article:51 single chip microcomputer - temperature sensor DS18B20
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
MoreDaily News
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- How haptic technology can enhance driving safety
Guess you like
- General welding specifications for MINI manufacturers
- Why constant current source simulation does not produce constant current
- [National Technology N32G457 Review] 1. Unboxing + Lighting
- The second article is a simple comparison between GD32VF103C START and ST official routines
- [GD32L233C-START Review] Part 3 PWM driving breathing light
- 【AT-START-F425 Review】 5. Brief analysis of timer interrupt code and implementation of breathing light
- Understanding GaN Thermal Analysis
- CC2652LP driving Δ∑ ADC - ADS1261
- Toyota car machine disassembly suitable for DIY modification
- EEWORLD University Hall----Nonlinear Control Systems