|
51单片机显示时分,求各位帮忙看看能否实现功能
[复制链接]
要求:b0 b1 b2 b3 位始终显示0;b4 b5显示分钟,b6 b7显示秒
#include
unsigned int t=0,z=0;
code unsigned char BCDto7SEG[10]={0x5f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f} ;
unsigned char d[8]={0,0,0,0,0,0,0,0};
void delay(void)
{unsigned int i;
for(i=0;i<123;i++);
}
void display(void)
{ unsigned char i;
for(i=0;i<8;i++)
{P0=BCDto7SEG[d];
P2=1<
delay();
P2=0;
}
}
int main(void)
{unsigned char i=0;
while(1)
{if(++i>=125)
{if(++t>5959)t=0;
d[7]=t%60%10;
d[6]=t%60/10;
d[5]=t/60%10;
d[4]=t/600;
i=0;
}
d[5]=t/60%10|0x80;
display();
}
}
|
|