#include<reg52.h>
sbit HC595_RCK=P1^0;
sbit HC595_SCK=P1^1;
sbit HC595_DATA=P1^4;
code unsigned char Shu_One_Array[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
code unsigned char Shu_Two_Array[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
void Shu_DATA(unsigned char Shu_Data_One,unsigned char Shu_Data_Two)
{ unsigned char i;
HC595_RCK=0;
for(i=0;i<8;i++)
{
HC595_SCK=0;
if(0==(Shu_Data_One&0x80))
{
HC595_DATA=0;
}
else
{
HC595_DATA=1;
}
HC595_SCK=1;
Shu_Data_One=Shu_Data_One<<1;
}
for(i=0;i<8;i++)
{
HC595_SCK=0;
if(0==(Shu_Data_Two&0x80))
{
HC595_DATA=0;
}
else
{
HC595_DATA=1;
}
HC595_SCK=1;
Shu_Data_Two=Shu_Data_Two<<1;
}
HC595_RCK=1;
}
void delay_1ms(int i)
{
int j;
for(;i>0;i--)
for(j=0;j<110;j++);
}
void Time0_Init()
{
TMOD|=0X01;
TH0=0xdc;
TL0=0x00;
TR0=1;
}
void main()
{
unsigned char m=0,j=0,k=0,Counter=0;
Time0_Init();
while(1)
{
if(1==TF0)
{
TF0=0;
TH0=0xdc;
TL0=0x00;
Counter++;
}
if(100==Counter)
{
Counter=0;
k++;
if(k>59)
{
k=0;
j++;
if(j>59)
{
j=0;
m++;
if(m>23)
{
m=0;
}
}
}
}
Shu_DATA(Shu_One_Array[m/10],Shu_Two_Array[0]);
delay_1ms(1);
Shu_DATA(Shu_One_Array[m%10],Shu_Two_Array[1]);
delay_1ms(1);
Shu_DATA(0x40,Shu_Two_Array[2]);
delay_1ms(1);
Shu_DATA(Shu_One_Array[j/10],Shu_Two_Array[3]);
delay_1ms(1);
Shu_DATA(Shu_One_Array[j%10],Shu_Two_Array[4]);
delay_1ms(1);
Shu_DATA(0x40,Shu_Two_Array[5]);
delay_1ms(1);
Shu_DATA(Shu_One_Array[k/10],Shu_Two_Array[6]);
delay_1ms(1);
Shu_DATA(Shu_One_Array[k%10],Shu_Two_Array[7]);
delay_1ms(1);
}
} |