#include<reg52.h>//2022880202
#define on 0
#define off 1
sbit fm=P2^3; //定义两个
int flagInt0=0;
int flagInt1=0;
void delay(unsigned int xms)
{
unsigned int i,j;
for(i=xms;i>0;i--);
for(j=112;j>0;j--); //给他一个时间延迟
}
void main(){
P1=0xff;
EA=1;//全局中断
EX0=1;//INTO中断允许
IT0=0;//触发方式为低电平触发
EX1=1;
IT0=1;
fm=on;//蜂鸣器响
delay(400);
fm=off;
while(1){ //循环
if(1==flagInt0)
{flagInt0=0;
P1=~P1;
delay(200);
}if(1==flagInt1)
{
fm=on;
delay(400);
fm=off;}
}
}
void processInt0() interrupt 0
{
flagInt0=1;
}
void processInt1() interrupt 2
{
flagInt1=1;
}