加上这些东西,将显示语句换成1602_display(i)即可,
当然你可以将其改为只显示2个数字
sbit rw=P1^4;
sbit rs=P1^3;
sbit lcden=P1^5;
#define db P2
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);
}
void 1602_display(uchar temp) //液晶显示一个8 位二进制数
{
uchar A1,A2,A3;
A1=temp/100;//分离百位、十位、个位
A2=temp/10%10;
A3=A2t%10;
write_com(0x80);//第1行,第1字
write_date(A1+0x30);
Delay1ms(1);
write_date( A2+0x30);
Delay1ms(1);
write_date(A3+0x30);
Delay1ms(1);
}
温馨提示:内容为网友见解,仅供参考