Program effect: The single-chip microcomputer controls the LCD display 1602 to display letters and numbers, and the user can change the io
program copyright: http://www.51hei.com
*/
#include
#define uchar unsigned char //macro definition
#define uint unsigned int
uchar code table[]="51HEI XING XING " ; //displayed letters
uchar code table1[]="51HEI MCU XUE YUAU" ;
sbit lcdrs=P1^0; //register selection pin
sbit lcdwr=P1^1; //read and write pin
sbit lcde=P1^2; //chip select pin
void delay(uchar x) //delay sub-function
{
uchar i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}
void write_com(uchar com) //write instruction sub-function
{ //Write according to 1602 LCD display protocol
P2=com;
lcdrs=0;
lcdwr=0;
delay(5);
lcde=0;
delay(5);
lcde=1;
}
void write_dat(uchar dat) //Write data sub-function
{
P2=dat;
lcdrs=1;
lcdwr=0;
delay(5);
lcde=0;
delay(5);
lcde=1;
}
void init() //Initialization sub-function
{
write_com(0x01); //Clear screen
write_com(0x3f); //Function setting
write_com(0x0d); //Display control
write_com(0x06); //Input mode setting
}
void main()
{
uchar i; //Define local variables
init();
write_com(0x80+0x02+0x10); //Pointer position
for(i=0;i<15;i++) //Display
{
write_dat(table[i]);
delay(50); //Delay, used to adjust speed mismatch
}
write_com(0x80+0x40+0x10);
for(i=0;i<16;i++)
{
write_dat(table1[i]);
delay(50);
}
for(i=0;i<16;i++)
{
write_com(0x18);
delay(50);
}
while(1);
}
Previous article:Program to scan keyboard using microcontroller interrupt
Next article:Calculation of accurate delay value in single chip microcomputer C language
Recommended ReadingLatest update time:2024-11-16 16:03
- Popular Resources
- Popular amplifiers
- Single-chip microcomputer C language programming and simulation
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Principles and Applications of Single Chip Microcomputers and C51 Programming (3rd Edition) (Xie Weicheng, Yang Jiaguo)
- stm32+lcd1602 example
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Embedded Learning丨4412 Development Board-uboot Source Code-Assembly-Source Code Analysis (I)
- Using the I2C Bus
- 【Qinheng RISC-V core CH582】Learning material collection
- CCS cannot connect to F280049C Launchpad
- What topics do electronic engineers like?
- Chips are also being counterfeited? How to develop a keen eye and identify "real and fake chips" in the arena!
- I have some hesitations about job hopping, I hope you can give me some advice
- Tips for you: How to design an excellent 5G small base station
- Essential knowledge about gas detectors
- How to Optimize DSP Power Budget