/*數碼管的動態顯示不是那么難,只要屢敗屢戰就好*/
//****************************
#include<reg52.h>
#define unit unsigned int
#define uchar unsigned char
//****************************
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
//****************************
uchar code tableduan[]={
0xfe,0xfd,0xfb,
};
uchar a,b,c;
//***************************
void main()
{
TMOD=1;
TH0=(65536-1000)/256;
TL0=(65536-1000)%256;
EA=1; //開中斷
ET0=1; //開定時器中斷;
TR0=1; //開定時器;
a=0;
b=0;
c=0;
while(1)
{
if(a==5)
{
a=0;
P0=tableduan[c];
c++;
P2=table[b++];
if(c==3)
{
c=0;
b=0;
}
}
}
}
void time_0() interrupt 1
{
a++;
TH0=(65536-1000)/256;
TL0=(65536-1000)%256;
}
|