麻烦帮我看看这段程序中value 1,2,3,4再整段程序有什么用?详细作用。
时间:10-02
整理:3721RD
点击:
void clock_h_l()
{
static uchar value,value1,value2,value3,value4;
if((table_dht11[2] >= t_high)) //温度上限报警
{
value1 ++; //消除温度在边界时的干扰
if(value1 > 2)
{
flag_w_bj_en = 1;
}
}
else if((table_dht11[2] <= t_low)) //温度下限报警
{
value2 ++; //消除温度在边界时的干扰
if(value2 > 2)
{
flag_w_bj_en = 1;
}
}
else
{
flag_w_bj_en = 0;
value1 = 0;
value2 = 0;
}
if((table_dht11[0] >= s_high)) //湿度上限报警
{
value3 ++; //消除湿度在边界时的干扰
if(value3 > 2)
{
flag_s_bj_en = 1;
}
}else if((table_dht11[0] <= s_low)) //湿度下限报警
{
value4 ++; //消除湿度在边界时的干扰
if(value4 > 2)
{
flag_s_bj_en = 1;
}
}else
{
flag_s_bj_en = 0;
value3 = 0;
value4 = 0;
}
if((flag_w_bj_en == 1) ||
(flag_s_bj_en == 1) ||
(pm >= s_pm) ||
(guangxian >= qiang_gx) || (guangxian <= ruo_gx))
{
value ++;
if(value >= 2)
beep = ~beep; //蜂鸣器报警
}
else
{
beep = 1;
value = 0;
}
}
value 1,2,3,4在这里只是做计数用的变量。程序运行到此value1自+1,if(value1 > 2),判断value1=3时执行花括号内语句。
计数器