Two-digit digital tube dynamic display C language program + circuit diagram

2020-12-15 14:52:11

51 single chip microcomputer digital tube driver written in c language The following is the circuit diagram:

Development of Single Chip Microcomputer

 
#include
#define uint unsigned int
void delay7ms(void)   //误差 -0.217013888891us
{
    unsigned char a,b;
    for(b=208;b>0;b--)
        for(a=14;a>0;a--);
}
void delay2ms(void)   //误差 -0.217013888889us
{
    unsigned char a,b;
    for(b=80;b>0;b--)
        for(a=10;a>0;a--);
}
 
void main(void)
{
uint led[10]={0xc0,0xf9,0xa4, 0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
uint m,n=0,a=0;
for(m=0;m<=10;m++)
{
while(a<30)
  {
    if(m==10)
    {
  m=0;
     n++ ;
     if(n==10)
     n=0;
 }
   P0=led[m];
   P2=0x40;
   delay7ms();
   P2=0x00;
   delay2ms();
   P0=led[n];
   P2=0x80;
   delay7ms();
   P2=0x00;
   delay2ms();
 
 a++;
  }
   a=0;
}
}