#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar light,f;
sbit LED1=P1^0;
sbit LED2=P1^1;
sbit LED3=P1^2;
sbit LED4=P1^3;
sbit LED5=P1^4;
sbit LED6=P1^5;
sbit LED7=P1^6;
sbit LED8=P1^7;
void delay_ms(int x)
{
uchar i;
while(i--)
for(i=0;i<125;i++)
;
}
void flicker(void)
{
P1=0X00;
delay_ms(200);
P1=0xff;
delay_ms(200);
}
void main(void)
{
IT0=1;
EX0=1;
IT1=1;
EX1=1;
PX0=0;
PX1=1;
EA=1;
light=0x01;
f=1;
while(1)
{
switch(f)
{
case1:flicker();break;
case2:void int0()interrupt 0;break;
case3:void int1()interrupt 1;break;
}
delay_ms(200);
}
}
void int0()interrupt 0
{
LED2=1;
LED4=1;
LED6=1;
LED8=1;
}
void int1()interrupt 1
{
LED1=1;
LED3=1;
LED5=1;
LED7=1;
}
#define uchar unsigned char
#define uint unsigned int
uchar light,f;
sbit LED1=P1^0;
sbit LED2=P1^1;
sbit LED3=P1^2;
sbit LED4=P1^3;
sbit LED5=P1^4;
sbit LED6=P1^5;
sbit LED7=P1^6;
sbit LED8=P1^7;
void delay_ms(int x)
{
uchar i;
while(i--)
for(i=0;i<125;i++)
;
}
void flicker(void)
{
P1=0X00;
delay_ms(200);
P1=0xff;
delay_ms(200);
}
void main(void)
{
IT0=1;
EX0=1;
IT1=1;
EX1=1;
PX0=0;
PX1=1;
EA=1;
light=0x01;
f=1;
while(1)
{
switch(f)
{
case1:flicker();break;
case2:void int0()interrupt 0;break;
case3:void int1()interrupt 1;break;
}
delay_ms(200);
}
}
void int0()interrupt 0
{
LED2=1;
LED4=1;
LED6=1;
LED8=1;
}
void int1()interrupt 1
{
LED1=1;
LED3=1;
LED5=1;
LED7=1;
}