#include<AT89X51.h>
#define uint unsigned int
#define uchar unsigned char
uchar code table_h[]={
0x1C,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,
0x1C,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,
0x1C,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,
0x1C,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,
0x1C,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,
0x1C,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,
0x1C,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,
0x1C,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,
0x1C,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,
0x1C,0x18,0x18,0x18,0x18,0x18,0x18,0x3C,
};
uchar code table_l[]=
{ 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
uchar i=0,j=0;
void Timer_init();
viod refresh_led();
void main()
{
Timer_init();
while(1)
{;
}
}
void Timer_init()
{
TMOD=0X01;
TH0=(65535-500)/256;
TL0=(65535-5000)%256;
ET0=1 ;
TR0=1;
EA=1;
}
void Timer0() interrupt 1
{TH0=(65535-3000)/256;
TL0=(65535-3000)%256;
if(i>=112){i=0;}
refresh_led();
}
Void refresh_led()
{
switch(j)
{ case 0:P0=~table_1[0];
Break;
case 1:P0=~table_1[1];
Break;
case 2:P0=~table_1[2];
Break;
case 3:P0=~table_1[3];
Break;
case 4:P0=~table_1[4];
Break;
case 5:P0=~table_1[5];
Break;
case 6:P0=~table_1[6];
Break;
case 7:P0=~table_1[7];
Break;
default:
break;}}
P2=table_h[i+j];
i++;
if(7==j++)
{J=0;}
程序是這樣的
|