P1 = 0xfb;
Delay(300);
P2 =LEDData[m%10]; //显示十位
DIAN = 0; //显示小数点
P1 = 0xfd;
Delay(300);
P2 =LEDData[m/10]; //显示百位
P1 = 0xfe;
Delay(300);
P1 = 0xff; //关闭显示
}
/*****显示报警温度子程序*****/
Disp_alarm(uchar baojing)
{
P2 =0xc6; //显示C
P1 = 0xf7;
Delay(200);
P2 =LEDData[baojing%10]; //显示十位
P1 = 0xfb;
Delay(200);
P2 =LEDData[baojing/10]; //显示百位
P1 = 0xfd;
Delay(200);
if(set_st==1)P2 =0x89;
else if(set_st==2)P2 =0xc7; //上限H、下限L标示
P1 = 0xfe;
Delay(200);
P1 = 0xff; //关闭显示
}
/*****报警子程序*****/
void Alarm()
{
if(x>=10){beep_st=~beep_st;x=0;}
if((m>=shangxian&&beep_st==1)||(m<xiaxian&&beep_st==1))BEEP=0;
else BEEP=1;
}
/*****主函数*****/
void main(void)
{
uint z;
InitTimer(); //初始化定时器
EA=1; //全局中断开关
TR0=1;
ET0=1; //开启定时器0
IT0=1;
IT1=1;
check_wendu();
check_wendu();
for(z=0;z<300;z++)
{
Disp_init();
}
while(1)
{
if(SET==0)
{
Delay(2000);
do{}while(SET==0);
set_st++;x=0;shanshuo_st=1;
if(set_st>2)set_st=0;
}
if(set_st==0)
{
EX0=0; //关闭外部中断0
EX1=0; //关闭外部中断1
check_wendu();
Disp_Temperature();
Alarm(); //报警检测
}
else if(set_st==1)
{
BEEP=1; //关闭蜂鸣器
EX0=1; //开启外部中断0
EX1=1; //开启外部中断1
if(x>=10){shanshuo_st=~shanshuo_st;x=0;}
if(shanshuo_st) {Disp_alarm(shangxian);}
}
else if(set_st==2)
{
BEEP=1; //关闭蜂鸣器
EX0=1; //开启外部中断0
EX1=1; //开启外部中断1
if(x>=10){shanshuo_st=~shanshuo_st;x=0;}
if(shanshuo_st) {Disp_alarm(xiaxian);}
}
}
}
/*****END*****/
DS18B20.h:
(责任编辑:admin) |