1602.h

来自「单片机设计存档」· C头文件 代码 · 共 60 行

H
60
字号
#ifndef _1602_H_
#define _1602_H_

void wait_1602()   //判断闲忙
{
	P0=0xff;
	do
	{
		RS=0;  
		RW=1;
		EN=0;
		EN=1;
	}while(BUSY==1);
}

void write_cmd(uint8 cmd)  //写指令
{
	wait_1602();
	EN=0;
	RS=0;
	RW=0;
	P0=cmd;
	EN=0;
	EN=1;
	EN=0;
}

void write_dat(uint8 dat)  //写数据
{
	wait_1602();
	EN=0;
	RS=1;
	RW=0;
	P0=dat;
	EN=0;
	EN=1;
	EN=0;
}

void write_string(uint8 add,uint8 *p)  //写字符串
{
	write_cmd(add);
	while(*p!='\0')
	{
		write_dat(*p++);
	}
}

void init_1602()
{
	write_cmd(0x38);     //开显示
	write_cmd(0x0c);
	write_cmd(0x06);
	write_cmd(0x01);     //清屏
	write_string(0x80,word1);
	write_string(0xc0,word2);
}

#endif

⌨️ 快捷键说明

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