程序如下
#include"reg51.h"
#define uint unsigned int
#define uchar unsigned char
sbit P1_0=P1^0;
const tab1[]={0xf0,0x0f0,0xf0,0x0f0,0xf0,0x0f0,
0xaa,0x55,0xaa,0x55,0xaa,0x55,0xff,};
const tab2[]={0xfe,0xfd,0xfd,0xf7,0xef,0xdf,0xbf,0x7f,
0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xff,
0xfe,0xfd,0xfd,0xf7,0xef,0xdf,0xbf,0x7f,
0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xff,};
uchar a;
void delay()
{
uint i,j;
for(i=0;i<256;i++)
for(j=0;j<256;j++)
{;}
}
void int1()interrupt 0
{ a=a+1;
if(a==1)
{uchar i;
for(i=0;i<14;i++)
{P0=tab1[i];
delay();}
}
if(a==2)
{ uchar i;
for(i=0;i<33;i++)
{ P0=tab2[i];
delay();}
a=0;
}
}
void int2()interrupt 1
{ P1_0=0;
delay();
P1_0=1;
}
void main(void)
{ IE=0x85;
IP=0x04;
TCON=0x00;
a=0;
while(1)
{uchar x;
for(x=0;x<23;x++)
{ P0=-P0;
delay();}
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>