#include<reg52.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
uchar num,temp,aa;
sbit dula = P1^0;//数码管段控制
sbit wela = P1^1;//数码管位控制
sbit Leden=P1^2;//LED灯控制端
sbit Line=P1^3;//点阵行控制端
uchar code table[]={
0X3f,0X06,0X5b,0x4f
,0x66,0x6d,0x7d,0x7f
,0x6f,0x77,0x7c,0x39
,0x5e,0x79,0x71,0x00};
void choose();
void delay(uint z);
void main()
{
TMOD=0X01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
num=0;
aa=0;
choose();
P0=temp;
temp=0xfe;
Leden=0;
wela=1;
P0=0x00;
wela=0;
dula=1;
P0=table[0];
dula=0;
while(1)
{
Leden=1;
P0=temp;
delay(1000);
temp=_crol_(temp,1);
Leden=0;
}
}
void choose()
{
Line=1;
P0=0X00;
Line=0;
/* wela=1;
P0=0xff;
wela=0; */
Leden=1;
P0=0xff;
Leden=0;
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void
time0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
aa++;
if(aa==20)
{
aa=0;
num++;
if(num==16)
{
num=0;
}
dula=1;
P0=table[num];
dula=0;
}
}
一周热门 更多>