外部中断0引脚接一个开关,p1.0接一个发光二极管,开关闭合一次,发光二极管改变一次状态,用单片机中断编程
# include <reg52.h>
sbit L1=P1^0; //指示灯
main ()
{
EA = 1; //开总中断
EX0=1;//开外部中断
while(1);//死循环等待中断
}
void Interrupt1 (void) interrupt 0 //外部中断处理函数
{
L1=!L1;//改变一次LED
}
sbit L1=P1^0; //指示灯
main ()
{
EA = 1; //开总中断
EX0=1;//开外部中断
while(1);//死循环等待中断
}
void Interrupt1 (void) interrupt 0 //外部中断处理函数
{
L1=!L1;//改变一次LED
}
温馨提示:答案为网友推荐,仅供参考