#include "reg52.h"
sbit L1=P0^0;
sbit L8=P0^7;
sbit YMQ_A=P2^5;
sbit YMQ_B=P2^6;
sbit YMQ_C=P2^7;
void Delay(unsigned xms) //@11.0592MHz
{
while(xms--);
}
void InitHC138(unsigned char n)
{
switch(n)
{
case 4:
YMQ_C=1;
YMQ_B=0;
YMQ_A=0;
break;
case 5:
YMQ_C=1;
YMQ_B=0;
YMQ_A=1;
break;
case 6:
YMQ_C=1;
YMQ_B=1;
YMQ_A=0;
break;
case 7:
YMQ_C=1;
YMQ_B=1;
YMQ_A=1;
break;
}
}
void Working()
{
InitHC138(4);
L1=0;
Delay(60000);
L1=1;
Delay(60000);
}
void Init_INT0()
{
IT0=1; //下降沿触发
EX0=1; //外部中断0打开
EA=1; //总中断打开
}
void ServiceINT0() interrupt 0
{
L8=0;
Delay(60000);
Delay(60000);
Delay(60000);
Delay(60000);
Delay(60000);
Delay(60000);
L8=1;
}
void main()
{
Init_INT0();
while(1)
{
Working();
}
}
//P3^2对应外部中断5和按键5