char get_hinder_num()
{
......
}
char get_count_down(char hinder_num)
{
......
}
//报警函数
void beep()
{
......
}
flag_delay = 1 //等待标志
void main()
{
char hinder_num = 0
char count_down = 0
while(1)
{
while(hinder_num == 0){ hinder_num = get_hinder_num()} //发生阻碍跳出
count_down = get_count_down() //获取倒计时
if (count_down == 0){beep()} //倒计时为0,立即报警
else
{
flag_delay = 1
......//使用定时器开始倒计时,根据count_down确定倒计时间
//时间到把flag_delay置为0
while(flag_delay) //等待
{
if (hinder_num != get_hinder_num()) //如果阻碍数量发生变化,退出等待
李逗 {
......//关闭定时器
break
}
慧橘 }
}
}
}
void main(){
unsigned char i=0x0a
P3=0x00
P1=0X00
TMOD=0X01
TH0=0X3C//设哪咐置定时100ms初值
TL0=0XB0
EA =1// ;CPU开中断
ET0 =1 // ;定时器0允许中断
while(1){
if (P3!=0x00){
TR0=1
while(1)
}
}
}
***** interrupt()//定李迟纯时器0中断自己查一下怎旦改么写
{
TH0=0X3C
TL0=0XB0
if(I!=0X00)
{
return
}else
{
i=0X0A
P3.7^=p3.7
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)