80C51单片机的LCD显示屏1602怎么连线
展开全部
需11根IO线,8位数据线,为方便数据传输,最好占一个完整的端口,三根控制线,使能信号E,命令/数据选择RS,读写控制信号WR,可以用任意三个IO口,可以参考现成的单片机开发板,并且程序也可以参考别人的
sbit rw=P1^4;
sbit rs=P1^3;
sbit lcden=P1^5;
#define db P2
void Delay1ms(uint i) //1ms延时程序
{
uint j;
for(;i>0;i--)
{
for(j=0;j<164;j++)
{;}
}
}
void write_com(uchar com)//液晶屏写命令
{
db=com;
rs=0;
rw = 0;
lcden=0;
Delay1ms(12);
lcden=1;
Delay1ms(12);
lcden=0;
}
void write_date(uchar date)//液晶屏写数据
{
db=date;
rs=1;
rw = 0;
lcden=0;
Delay1ms(12);
lcden=1;
Delay1ms(12);
lcden=0;
}
void init2()//液晶屏初始化
{
rw=0;
write_com(0x38);
Delay1ms(12);
write_com(0x0f);
Delay1ms(12);
write_com(0x06);
Delay1ms(12);
write_com(0x01);
Delay1ms(12);
}
sbit rw=P1^4;
sbit rs=P1^3;
sbit lcden=P1^5;
#define db P2
void Delay1ms(uint i) //1ms延时程序
{
uint j;
for(;i>0;i--)
{
for(j=0;j<164;j++)
{;}
}
}
void write_com(uchar com)//液晶屏写命令
{
db=com;
rs=0;
rw = 0;
lcden=0;
Delay1ms(12);
lcden=1;
Delay1ms(12);
lcden=0;
}
void write_date(uchar date)//液晶屏写数据
{
db=date;
rs=1;
rw = 0;
lcden=0;
Delay1ms(12);
lcden=1;
Delay1ms(12);
lcden=0;
}
void init2()//液晶屏初始化
{
rw=0;
write_com(0x38);
Delay1ms(12);
write_com(0x0f);
Delay1ms(12);
write_com(0x06);
Delay1ms(12);
write_com(0x01);
Delay1ms(12);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询