LED静态显示2位秒表 - 武恩赐博客💻

LED静态显示2位秒表

#include <REGX51.H>     
void time50ms(unsigned char i)
unsigned char led[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
{
    unsigned char k;
    for(k=0;k<i;k++)            
    {
        TH0=(65536-50000)/256;  
        TL0=(65536-50000)%256;  
        TR0=1;                    
        while(!TF0);            
        TF0=0;                    
    }
}

void main()                        
{
    unsigned char i;            
    TMOD=0x01;                    
    P1=0xff;                    
    P2=0xff;                    
    while(1)                    
    {
        for(i=0;i<60;i++)        
        {
            P1=led[i/10];        
            P2=led[i%10];        
            time50ms(20);    
        }
    }
}
无标签
打赏
评论区
头像