第1个回答 2020-06-08
#include<reg51.h>
sbit P32=P3^2;
void main()
{
IT0=1; //外部中断0连沿触发方式
EX0=1;//使能外部中断0
EA=1; //开部中断
while(1);
}
void int0() interrupt 0 //外部中断0程序入口
{
static unsigned char Bit=0;
if(Bit<=0)
Bit =15;
switch(Bit)
{
case 0:P3 = 0xef;
break;
case 1:P3 = 0xdf;
break;
case 2:P3 = 0xbf;
break;
case 3:P3 = 0x7f;
break;
}
Bit--;
}