自己搞了半天,也没出来,求大佬帮我看看显示三个数字,lcd只能显示三个方块,其他的显示都没问题,哪里出现问题了吗??
if(set==3)
{
write_com(0x38);
write_com(0x01);
Display_data();
write_com(0x80+0x40+4);
write_data(bj1);
write_data(bj2);
write_data(bj3);
FENG=1;
}//按键三次时lcd显示的内容
uchar bj1=0,bj2=0,bj3=0;
void time0_int(void) interrupt 1 //bj1-3在中断里赋值了
{
uchar count;
TL0=0xb0;
TH0=0x3c;
count++;
if(count==10)
{
count=0;
if(flag2==0)
LED_Y=1;
else
LED_Y=0;
if(flag7==0)
LED_R=1;
else
LED_R=0;
if(flag2==1&&flag7==0)
{
FENG=!FENG;
jdq1=1;
jdq2=0;
bj1=1;
}
if(flag2==0&&flag7==1)
{
FENG=!FENG;
jdq1=1;
jdq2=0;
bj2=1;
}
if(flag2==1&&flag7==1)
{
FENG=!FENG;
jdq1=1;
jdq2=0;
bj3=1 ;
}
if(flag2==0&&flag7==0)
{
FENG=1;
jdq1=0;
jdq2=1;
}
}
}
****************display.h头文件*****************
- //宏定义
- #define uint unsigned int
- #define uchar unsigned char
- //LCD管脚声明
- sbit LCDRS = P1^0;
- sbit LCDEN = P1^1;
- //初始画时显示的内容
- uchar code Init1[]="HY : YW: ";
- uchar code Init2[]="HH : HY: ";
- uchar code Init3[]=" ALARM RECORDS ";
- //LCD延时
- void LCDdelay(uint z)
- {
- uint x,y;
- for(x=z;x>0;x--)
- for(y=10;y>0;y--);
- }
- //写命令
- void write_com(uchar com)
- {
- LCDRS=0;
- P0=com;
- LCDdelay(5);
- LCDEN=1;
- LCDdelay(5);
- LCDEN=0;
- }
- //写数据
- void write_data(uchar date)
- {
- LCDRS=1;
- P0=date;
- LCDdelay(5);
- LCDEN=1;
- LCDdelay(5);
- LCDEN=0;
- }
- //1602初始化
- void Init1602()
- {
- write_com(0x38);//屏幕初始化
- write_com(0x0c);//打开显示 无光标 无光标闪烁
- write_com(0x06);//当读或写一个字符是指针后一一位
- write_com(0x01);//清屏
- }
- void Display_1602(uchar NOW_GAS,uchar NOW_CO,uchar SET_GAS,uchar SET_CO)
- {
- uchar i=0;
- write_com(0x80);//设置位置
- for(i=0;i<16;i++)
- {
- write_data(Init1[i]);
- }
- write_com(0x80+0x40);//设置位置
- for(i=0;i<16;i++)
- {
- write_data(Init2[i]);
- }
- write_com(0x80+4);
- write_data('0'+NOW_GAS/100);
- write_data('0'+NOW_GAS/10%10);
- write_data('0'+NOW_GAS%10);
- write_com(0x80+0x40+4);
- write_data('0'+SET_GAS/100);
- write_data('0'+SET_GAS/10%10);
- write_data('0'+SET_GAS%10);
- write_com(0x80+13);
- write_data('0'+NOW_CO/100);
- write_data('0'+NOW_CO/10%10);
- write_data('0'+NOW_CO%10);
- write_com(0x80+0x40+13);
- write_data('0'+SET_CO/100);
- write_data('0'+SET_CO/10%10);
- write_data('0'+SET_CO%10);
- }
- void Display_data()
- {
- uchar j=0;
- write_com(0x80);//设置位置
- for(j=0;j<16;j++)
- {
- write_data(Init3[j]);
- }
- }
复制代码
|