- #include<AT89X52.h>
- #include<intrins.h>
- unsigned char count,i;
- unsigned char code TABLE[]={0xe7,0xdb,0xbd,0x7e} ;
- void main()
- {
- count=0;
- TMOD=0x01;
- TL0=0X00;
- TH0=0X4C;
- TR0=1;
- EA=1;
- ET0=1;
- while(1)
- {
- for(i=0;i<4;i++)
- {
- P1=TABLE[i];
- }
-
-
- }
- }
- void t0interrupt(void) interrupt 1
- {
- TL0=0X00;
- TH0=0X4C;
- count++;
- if(count==20)
- {
- i=0;
- count=0;
- }
-
-
- }
复制代码- <img src="http://bbs.elecfans.com/forum.php?mod=image&aid=541492&size=300x300&key=591ba85311f98049&nocache=yes&type=fixnone" aid="attachimg_541492" alt="" border="0">大概就是想实现这个功能
复制代码
-
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
#include<AT89X52.h>
#include<intrins.h>
unsigned char count,i=0,j=0;
unsigned char code TABLE[]={0xe7,0xdb,0xbd,0x7e};
void main()
{
count=0;
TMOD=0x01;
TL0=0X00;
TH0=0X4C;
TR0=1;
EA=1;
ET0=1;
while(1)
{
if(i==1)
{
i=0;
switch(j)
{
case 0: P1=TABLE[0];j=1; break;
case 1: P1=TABLE[1];j=2; break;
case 2: P1=TABLE[2];j=3; break;
case 3: P1=TABLE[3];j=0; break;
}
}
// for(i=0;i<4;i++)
// {
// P1=TABLE[i];
// }
}
}
void t0interrupt(void) interrupt 1
{
TL0=0X00;
TH0=0X4C;
count++;
if(count==20)
{
i=1;
count=0;
}
}
一周热门 更多>