标题:
基于stc89c52rc的 按钮控制的外部中断
[打印本页]
作者:
朝朝1
时间:
2020-10-24 14:10
标题:
基于stc89c52rc的 按钮控制的外部中断
#include <reg52.h>
sbit LED = P1^0;
sbit wai = P3^2;
sbit key = P3^4;
void main()
{
int i;
IT0 = 1; //为下降沿触发中断
EX0 = 1; //外部中断0允许位
EA = 1; //打开总中断
while(1)
{
for(i=0;i<1000;i++) ; //延时函数
EA=1;
if(key==0)
{wai=0;}
if(key==1)
{wai=1;}
}
}
void int0_process() interrupt 0
{
unsigned int a;
a++;
if(a%2==0)
LED=0;
if(a%2==1)
LED=1; // LED = ~LED;
EA=0;
}
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1