#include "reg52.h"
sbit L1 = P0^0;
sbit L8 = P0^7;
void delay(unsigned char t)
{
while(t--);
}
void HC138()
{
P2 = (P2 & 0x1f) | 0x80;
}
void Working()
{
HC138();
L1 = 0;
delay(60000);
L1 = 1;
delay(60000);
}
//============================
void Init_INT0()
{
IT0 = 1;
EX0 = 1;
EA = 1;
}
void ServiceINT0() interrupt 0
{
L8 = 0;
delay(600000);
L8 = 1;
}
//==============================
void main()
{
Init_INT0();
while(1)
{
Working();
}
}
方法二
#include "reg52.h"
sbit L1 = P0^0;
sbit L8 = P0^7;
void delay(unsigned char t)
{
while(t--);
}
void HC138()
{
P2 = (P2 & 0x1f) | 0x80;
}
void Working()
{
HC138();
L1 = 0;
delay(60000);
L1 = 1;
delay(60000);
}
//============================
void Init_INT0()
{
IT0 = 1;
EX0 = 1;
EA = 1;
}
unsigned char state = 0;
void ServiceINT0() interrupt 0
{
state = 1;
}
void led()
{
if(state == 1)
{
L8 = 0;
delay(600000);
L8 = 1;
}
state = 0;
}
//==============================
void main()
{
Init_INT0();
while(1)
{
led();
Working();
}
}
标签:HC138,07,Working,中断,void,delay,外部,L1,L8 From: https://www.cnblogs.com/Unclesundada/p/17005137.html