#include <reg52.h>
sbit dula=P2^6;
sbit wela=P2^7;
#define uchar unsigned char
#define uint unsigned int
#define dearpot P0
uchar code temap[]={0x3F,0x06,0x5B,0x4F,
0x66,0x6D,0x7D,0x07,
0x7F,0x6F,0x77,0x7C,
0x39,0x5E,0x79,0x71,
0};
uchar code weiz[]={0xfe,0xfd,0xfb,0x7f,0xef,0xdf};
uchar TempData[8];
void delay (uint z);
void display(uchar tt,uchar aa);
uchar cc;
uint num;
void exmerpt0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
cc++;
}
void main()
{
uint num=9999;
TMOD=0X01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
TR0=1;
ET0=1;
while(1)
{
if(cc==10)
{
cc=0;
if(num>0)
{
num--;
}
if(num==0)
{
num=9999;
}
}
TempData[0]=temap[num/1000];
TempData[1]=temap[(num%1000)/100];
TempData[2]=temap[((num%1000)%100)/10];
TempData[3]=temap[((num%1000)%100)%10];
display(2,4);
}
}
void delay (uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void display(uchar tt,uchar aa)
{
uchar i;
for(i=0;i<aa;i++)
{
dearpot=0;
dula=1;
dula=0;
dula=1;
dearpot =TempData[i];
dula=0;
dearpot=0xff;
wela=1;
dearpot=weiz[i+tt];
wela=0;
delay(2);
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
uchar code weiz[] = {0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f}
一周热门 更多>