📄 lcd.c
字号:
#include <reg52.h>
unsigned char Status , Data ,Command , i ;
unsigned char code max197 [] = "MAX197AD转换 " ;
unsigned char code shuru [] = "输入电压: V";
#define LCD_Data P0
sbit LCD_RS =P1^2;
sbit LCD_E =P1^0;
sbit LCD_WR =P1^1;
LCDBusyWait() //等待LCD就绪
{
unsigned char Status;
LCD_RS=0;
LCD_WR=1;
LCD_Data=0xFF;
LCD_E=1;
Status=LCD_Data;
LCD_E=0;
while(Status & 0x80)
{
LCD_E=1;
Status=LCD_Data;
LCD_E=0;
}
LCD_WR=0;
return Status;
}
WriteLCD_Data( unsigned char Data ) //向LCD写入一个字节的数据
{
LCDBusyWait();
LCD_RS=1;
LCD_Data = Data;
LCD_E=1;
LCD_E=0;
}
WriteLCD_Command( unsigned char Command ) //向LCD写入一个字节的命令
{
LCDBusyWait();
LCD_RS=0;
LCD_Data=Command;
LCD_E=1;
LCD_E=0;
}
lcd_init ()
{
unsigned int i;
WriteLCD_Command(0x01); //清屏
for(i=0;i<2000;i++);
WriteLCD_Command(0x30); //功能设置8位界面,
for(i=0;i<2000;i++);
WriteLCD_Command(0x0C); //显示开,光、光标关,反白显示
for(i=0;i<2000;i++);
WriteLCD_Command(0x06); //DDRAM地址自加
for(i=0;i<2000;i++);
}
lcd_display ( unsigned char display_data[] )
{ i = 0;
while ( display_data[i] != '\0')
{
Data = display_data [i] ;
WriteLCD_Data(Data) ;
i++ ;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -