程序:
#include
#define DATA_PORT P0
sbit LCD12864_EN = P1^2;
sbit LCD12864_RSET = P1^3;
sbit LCD12864_RS = P1^0;
sbit LCD12864_RW = P1^1;
sbit LCD12864_PSB = P1^6;
void delay(unsigned int xms) //延时//
{
unsigned char i,j;
for(j = 0; j < xms; j++)
{
for(i = 0;i < 110;i++);
}
}
bit LcdBusyCheck(){
bit result;
LCD12864_RS = 0;
LCD12864_RW = 1;
LCD12864_EN = 1;
result = (bit)(DATA_PORT&0x80);
LCD12864_EN = 0;
return result;
}
void WriteCmdToLCD(unsigned char cmd)
{
// while(LcdBusyCheck());
delay(10);
LCD12864_RS = 0;
LCD12864_RW = 0;
LCD12864_EN = 1;
DATA_PORT = cmd;
delay(5);
LCD12864_EN = 0;
delay(5);
LCD12864_EN = 1;
}
void WriteDatToLcd(unsigned char dat)
{
//while(LcdBusyCheck());
delay(10);
LCD12864_RS = 1;
LCD12864_RW = 0;
LCD12864_EN = 1;
DATA_PORT = dat;
delay(5);
LCD12864_EN = 0;
delay(5);
LCD12864_EN = 1;
}
void WriteStrToLcd(unsigned char *str)
{
while(*str != '')
{
WriteDatToLcd(*str++);
delay(5);
}
}
void LcdPos(unsigned char x,unsigned char y)
{
unsigned char pos;
if(x == 1)
{
x = 0x80;
}else if(x == 2)
{
x = 0x90;
}else if(x == 3)
{
x = 0x88;
}else if(x == 4)
{
x = 0x98;
}
pos = x + y - 1;
WriteCmdToLCD(pos);
}
void LcdInit()
{
LCD12864_PSB = 1;
LCD12864_RSET = 0;
delay(10);
LCD12864_RSET = 1;
WriteCmdToLCD(0x30);
delay(5);
WriteCmdToLCD(0x30);
delay(5);
WriteCmdToLCD(0x18);
delay(5);
WriteCmdToLCD(0x10);
delay(5);
WriteCmdToLCD(0x01);
delay(5);
WriteCmdToLCD(0x06);
delay(5);
WriteCmdToLCD(0x0c);
delay(5);
}
int main()
{
P0 = 0xff;
P1 = 0xff;
LcdInit();
while(1)
{
LcdPos(1,1);
WriteStrToLcd(" 榆林学院 ");
delay(5);
LcdPos(2,1);
WriteStrToLcd("能源工程学院");
delay(5);
LcdPos(3,1);
WriteStrToLcd("51控制LCD12864");
delay(5);
LcdPos(4,1);
WriteStrToLcd("加油吧朋友们!!!");
delay(500);
}
}
Previous article:51 single chip temperature control alarm and time display program + Proteus simulation
Next article:Course Design of Single Chip Microcomputer 00 to 99 Stopwatch
Recommended ReadingLatest update time:2024-11-15 17:44
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- 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
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- There are already over 300 CircuitPython libraries
- Is LDO a DC/DC?
- EEWORLD University - Strengthen power knowledge through the TI Power Management Lab Kit (TI-PMLK) series
- [TI recommended course] #[High Precision Lab] Clock and Timing#
- How do you estimate the number of vias on the capacitors in the power supply section of a PCB? Do you need to drill a lot of vias if the capacitors don't carry a lot of current?
- The blueNRG-1 chip will burn out automatically when running the program (solved)
- Application of DSP repetitive control technology in inverter power supply system
- The ov7725 camera has serious distortion. What's going on?
- 【CH579M-R1】+Help: How to receive complete serial port data
- Regarding the calculation of the values of TA0CCR1 and TA0CCR2 configured by the PWM library function