/*******************************单片机抢答器*****************************//******必要的变量定义******/#include<>#define uchar unsigned char //宏定义uchar code table[]={0xfc,0x60,0xda,0xf2,0x66,0xb6,0xbe,0xe0,0xfe,0xf6};sbit k=P3^0; //开始键为 led=P3^6; //指示灯sbit k1=P2^0;sbit k2=P2^1;sbit k3=P2^2;sbit k4=P2^3;sbit k5=P2^4;sbit k6=P2^5;sbit k7=P2^6;sbit k8=P2^7;/******延时子程序******/void delay(uchar c){unsigned char a,b;for(;c>0;c--)for(a=142;a>0;a--)for(b=2;b>0;b--);}/******中断0子程序******/void int_0() interrupt 0{EX0=0; //关闭外中断0led=1; //关闭led{if(k1!=1)P0=table[1];P1=0xfe;if(k2!=1)P0=table[2];P1=0xfd;if(k3!=1)P0=table[3];P1=0xfb;if(k4!=1)P0=table[4];P1=0xf7;if(k5!=1)P0=table[5];P1=0xef;if(k6!=1)P0=table[6];P1=0xdf;if(k7!=1)P0=table[7];P1=0xbf;if(k8!=1)P0=table[8];P1=0x7f;}EX0=1; //开外中断0}/******主程序******/void main(){k=1; //开始键 为高电平led=1; //led为高电平 灯灭while(1){P2=0xff;if(k!=1){led=0; //led亮EA=1; //开总中断EX0=1; //开 外中断润徐寄存器IEIT0=0; //设置外中断触发控制为低电平触发}}}