8位共阴极数码管时钟程序求助
时间:10-02
整理:3721RD
点击:
8位共阴极数码管,前六位显示月日时,最后两位显示分钟,分钟要动态闪烁以显示出秒的效果,求怎么改程序,代码如下
#include<reg52.h>
unsigned char code tab[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char Led_Buf[8];
unsigned char month=11, day=27, hour=23, minute=22;
int time;
int count1=0, count2=0;
sbit LSA=P2^2;
sbit LSB=P2^3;
sbit LSC=P2^4;
//全灭
void int_1() interrupt 3
{
TH1=0X3C;
TL1=0X3D;
TF1=0;
}
void Delay(char iloop,char jloop)
{
char i=0, j=0;
for(;i<iloop;i++)
for(;j<jloop;j++)
;
}
void Display()
{
int i;
Led_Buf[0]=tab[minute%10];
Led_Buf[1]=tab[minute/10];
Led_Buf[2]=tab[hour%10];
Led_Buf[3]=tab[hour/10];
Led_Buf[4]=tab[day%10];
Led_Buf[5]=tab[day/10];
Led_Buf[6]=tab[month%10];
Led_Buf[7]=tab[month/10];
while(1){
for(i=0;i<8;i++)
{
/*
if(count==500){
Led_Buf[0]=0x00;
Led_Buf[1]=0x00;
count=0;
}*/
P0=Led_Buf[i];
P0=0;//消隐
P2=P2+4;
}
}
}
void main()
{
LSA=0;
LSB=0;
LSC=0;
P2 = 0;//Initialize
P0 = 0;
TMOD=0X11;
TH1=0X3C;
TL1=0XB0;
IE=0X88;
TR1=1;
while(1)
{
Display();
}
}
#include<reg52.h>
unsigned char code tab[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char Led_Buf[8];
unsigned char month=11, day=27, hour=23, minute=22;
int time;
int count1=0, count2=0;
sbit LSA=P2^2;
sbit LSB=P2^3;
sbit LSC=P2^4;
//全灭
void int_1() interrupt 3
{
TH1=0X3C;
TL1=0X3D;
TF1=0;
}
void Delay(char iloop,char jloop)
{
char i=0, j=0;
for(;i<iloop;i++)
for(;j<jloop;j++)
;
}
void Display()
{
int i;
Led_Buf[0]=tab[minute%10];
Led_Buf[1]=tab[minute/10];
Led_Buf[2]=tab[hour%10];
Led_Buf[3]=tab[hour/10];
Led_Buf[4]=tab[day%10];
Led_Buf[5]=tab[day/10];
Led_Buf[6]=tab[month%10];
Led_Buf[7]=tab[month/10];
while(1){
for(i=0;i<8;i++)
{
/*
if(count==500){
Led_Buf[0]=0x00;
Led_Buf[1]=0x00;
count=0;
}*/
P0=Led_Buf[i];
P0=0;//消隐
P2=P2+4;
}
}
}
void main()
{
LSA=0;
LSB=0;
LSC=0;
P2 = 0;//Initialize
P0 = 0;
TMOD=0X11;
TH1=0X3C;
TL1=0XB0;
IE=0X88;
TR1=1;
while(1)
{
Display();
}
}