lcd1602.c

来自「DS1302时钟芯片的驱动程序。希望对各位仁兄有用」· C语言 代码 · 共 54 行

C
54
字号
#include "reg52.h"
#include "lcd1602.h"
/************延时函数*/
void Delay(uint i)
{
while(i--);
}
/*写指令函数*/
void Write_Instruction(uchar x)
{
Delay(1000);
E=0;
RW=0;
RS=0;
LCDData=x;
E=1;
Delay(20);
E=0;
}
/*写单个数据的函数*/
void Write_Data(uchar x)
{
Delay(1000);
E=0;
RW=0;
RS=1;
E=1;
LCDData=x;
E=0;
}
/*清屏函数*/
void Cls(void)
{
Write_Instruction(0x01);
}
/*写入一串字符串函数*/
void Write_String(uchar x,uchar *p)
{ Write_Instruction(x);
while(*p!=0x00)
{Write_Data(*p);
p++;
if (x++==0x8f)
{Write_Instruction(0xc0);}
}
}
/*初始化函数*/
void InitLCD(void)
{Write_Instruction(0x38);
Delay(200);
Write_Instruction(0x0e);
Delay(200);
Write_Instruction(0x06);
Delay(200);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?