#include <reg52.h>
sbit ADD0 = P2^0;
sbit ADD1 = P2^1;
sbit ADD2 = P2^2;
typedef unsigned char uint8;
typedef unsigned int uint16;
typedef unsigned long uint32;
uint8 code ledchar[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
uint8 shuchar[6]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
uint8 i;
uint16 ci;
uint32 shu;
void main()
{
EA=1;
TMOD=0x01;
TH0=0xFC;
TL0=0x67;
ET0=1;
TR0=1;
while(1)
{
if(ci>=1000)
{
ci=0;
shu++;
shuchar[0]=ledchar[shu%10];
shuchar[1]=ledchar[shu/10%10];
shuchar[2]=ledchar[shu/100%10];
shuchar[3]=ledchar[shu/1000%10];
shuchar[4]=ledchar[shu/10000%10];
shuchar[5]=ledchar[shu/10000%10];
}
}
}
void Interrupt
timer0() interrupt 1
{
TH0=0xFC;
TL0=0x67;
ci++;
P0=0xFF;
switch(i)
{
case 0:ADD0=1;ADD1=1;ADD2=1;i++;P0=shuchar[0];break;
case 1:ADD0=0;ADD1=1;ADD2=1;i++;P0=shuchar[1];break;
case 2:ADD0=1;ADD1=0;ADD2=1;i++;P0=shuchar[2];break;
case 3:ADD0=0;ADD1=0;ADD2=1;i++;P0=shuchar[3];break;
case 4:ADD0=1;ADD1=1;ADD2=0;i++;P0=shuchar[4];break;
case 5:ADD0=0;ADD1=1;ADD2=0;i=0;P0=shuchar[5];break;
default:break;
}
}
还是蛮有用的
一周热门 更多>