LCD1602液晶显示


#include<reg52.h>
sbit RS=P3^5;
sbit RW=P3^6;
sbit EN=P3^4;
#define uchar unsigned char
#define uint unsigned int
//读状态
void Read_state()
{
	uchar busy;
   	P0=0xff;
	RS=0;
	RW=1;
	do
	{
		EN=1;
		busy=P0;
		EN=0;

	}while(busy & 0x80);
}
//写指令
void Write_order(uint cmd)
{
	Read_state();
	RS=0;
	RW=0;
	P0=cmd;
	EN=1;
	EN=0;
}
//写数据
void Write_data(uint dat)
{
	Read_state();
	RS=1;
	RW=0;
	P0=dat;
	EN=1;
	EN=0;
}
void main()
{
	uchar *a[]={"Junday ","Monday "," Tuesday ","Wednesday ","Thursday ","Friday ","Saturday "};
	uchar *pa;
	uint i,k=1000;
	Write_order(0x38);//设置16*2显示
	Write_order(0x0c);//开显示 不显示光标 光标不闪烁
	Write_order(0x01);//清屏
	Write_order(0x07);//地址指针移位命令
	Write_order(0x80|0x10);//显示地址
	for(i=0;i<7;i++)
	{
		pa=a[i];
		while(*pa!='\0')
		{
			Write_data(*pa++);
			while(k--);
		}
		k=1000;
	}
	while(1);	
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

月牙 ,呐

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值