这段代码怎么改能实现从00.00到59.99s的变化,每十毫秒变化一次

img

#include<reg51.h>
unsigned char sec=0;
unsigned char s1[] = {0x3f, 0x06, 0x5b, 0x4f, 
0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x77, 
0x7c, 0x39, 0x5e, 0x79, 0x71, 0x73, 0x3e, 
0x31, 0x6e, 0x76, 0x38, 0x00};//共阴
unsigned char s2[] = {0xc0, 0xf9, 0xa4, 0xb0, 
0x99, 0x92, 0x82, 0xf8, 0x80, 0x90, 0x88, 
0x83, 0xc6, 0xa1, 0x86, 0x8e, 0x8c, 0xc1, 
0xce, 0x91, 0x89, 0xc7, 0xff};//共阳
unsigned char s3[] = {0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10}; //带小数点的从0-9
void delay(unsigned char i)
{
while(i--)
{
unsigned int t;
for(t=0;t<120;t++);
}
}
void seg()
{
    P0=0x01;
    P1=s2[sec/10];
    delay(2);
    P1=0xff;
    
    P0=0x02;
    P1=s3[sec%10];
    delay(2);
    P1=0xff;
    
    P0=0x04;
    P1=s2[sec%10];
    delay(2);
    P1=0xff;
    
    P0=0x08;
    P1=s2[sec%10];
    delay(2);
    P1=0xff;
}
void main()
{
    unsigned char num=0;
    while(1)
    {
        seg();
        //unsigned char num=0;
        if(num<50)
        num++;
        else
        {
            num=0;
            if(sec<60)
            sec++;
            else
            sec=0;
        }
    }
}

#include<reg51.h>
unsigned int sec=0;
unsigned char s1[] = {0x3f, 0x06, 0x5b, 0x4f, 
0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x77, 
0x7c, 0x39, 0x5e, 0x79, 0x71, 0x73, 0x3e, 
0x31, 0x6e, 0x76, 0x38, 0x00};//共阴
unsigned char s2[] = {0xc0, 0xf9, 0xa4, 0xb0, 
0x99, 0x92, 0x82, 0xf8, 0x80, 0x90, 0x88, 
0x83, 0xc6, 0xa1, 0x86, 0x8e, 0x8c, 0xc1, 
0xce, 0x91, 0x89, 0xc7, 0xff};//共阳
unsigned char s3[] = {0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10}; //带小数点的从0-9
void delay(unsigned char i)
{
while(i--)
{
unsigned int t;
for(t=0;t<120;t++);
}
}
void seg()
{
    P0=0x01;
    P1=s2[sec/1000];
    delay(2);
    P1=0xff;
    
    P0=0x02;
    P1=s3[(sec/100)%10];
    delay(2);
    P1=0xff;
    
    P0=0x04;
    P1=s2[(sec/10)%10];
    delay(2);
    P1=0xff;
    
    P0=0x08;
    P1=s2[sec%10];
    delay(2);
    P1=0xff;
}
void main()
{
    unsigned char num=0;
    while(1)
    {
        seg();
        //unsigned char num=0;
        if(num<50)
        num++;
        else
        {
            num=0;
            if(sec<6000)
            sec++;
            else
            sec=0;
        }
    }
}

这不是每十毫秒变化一次吧,我把4个延时改成 delay(1.25);num改成<2(这样应该是每十毫秒变化一次了),发现最后一位变化太快了,来不及观察到数字变化