void main()
{
lcd_init();//1602初始化
Int0Init();//外部中断初始化
Time0_Init();//定时器初始化
lcd_write_str(0,0,"Speed: /s ");
lcd_write_str(0,1,"L: /s H: /s");
Display_Arlam();//显示上下限
while(1)
{
Keyscan();//按键扫描
if(SetN == 0)//不在设置状态下
{
//显示脉冲
lcd_write_char(7,0,TEMP_M1/100+48);//显示百位
lcd_write_char(8,0,TEMP_M1%100/10+48);//显示十位
lcd_write_char(9,0,TEMP_M1%10+48);//显示十位
if(TEMP_M1 < S_L)//脉冲小于下限,说明滴速过慢
{
MotorCW();//电机顺时针转动
BEEP = 0;//蜂鸣器报警
}
else if(TEMP_M1 > S_H)//脉冲大于上限,说明滴速过快
{
MotorCCW();//电机逆时针转动
BEEP = 0;//蜂鸣器报警
}
else
BEEP = 1;
if(shidu == 0)//检测到没有湿度,说明没药水了,蜂鸣器报警
{
BEEP = 0;
}
else
{
if(TEMP_M1 > S_L && TEMP_M1<S_H)
{
BEEP = 1;//关闭蜂鸣器
}
}
}
}
}