数码管数字飞入

来源:互联网 发布:网络报警 编辑:程序博客网 时间:2024/05/06 10:06

原理图同上

源程序:

#include<reg51.h>
charTAB[11]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff};
char disp[10][4]={{10,10,10,8},
                 {10,10,8,10},
     {10,8,10,10},
     {8,10,10,10},
     {8,10,10,0},
     {8,10,0,10},
     {8,0,10,10},
     {8,0,10,5},
     {8,0,5,10},
     {8,0,5,1},
    };
void delay(int x);
void scan(int x);
void main()
{
  int i,j,k;
  while(1)
  {
   P3=0x08;
 for(i=0;i<10;i++)
     {
  P3=0x08;
    for(j=0;j<4;j++)
         {
        k=disp[i][j];
        P2=TAB[k];
      delay(15);
      P3>>=1;
         }
   }
 P3=0x00;
 delay(600);
  }
}
void delay(int x)
{
  int i,j;
  for(i=0;i
   for(j=0;j<120;j++);
}

0 0
原创粉丝点击