#include<reg51.h>
sbit error=P3^3;
sbit start=P3^4;
sbit buzz=P1^7;
void Delay(unsigned int t)
{
unsigned int x,y;
for(x=t;t>0;t--)
for(y=110;y>0;y--)
{
if(start==0)
return;
}
}
void main()
{
EX1=1; //外部中断1允许
IT1=0; //电平触发中断
EA=1; //总中断允许
while(1)
{
if(start==1)
{
P1=0xfe; //工序1,完成后进入工序2
Delay(500);
P1=0xfd; //工序2,完成后进入工序3
Delay(500);
P1=0xfb;
Delay(500);
P1=0xf7;
Delay(500);
P1=0xef;
Delay(500);
P1=0xdf;
Delay(500);
P1=0x8f;
Delay(500); //7道工序完成,重新开始循环
}
else
P1=0xff;
}
}
void int1_isp() interrupt 2 //外部中断1中断服务函数
{
if(start==1)
buzz=0; //报警
}
|