欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

專注電子技術學習與研究
當前位置:單片機教程網 >> MCU設計實例 >> 瀏覽文章

51單片機一個輸出口顯示多位輸出

作者:余春雨老師   來源:本站原創   點擊數:  更新時間:2014年04月26日   【字體:

電路圖

#include"reg51.h"
sbit LE0=P3^0;
sbit LE1=P3^1;
sbit LE2=P3^2;
sbit LE3=P3^3;
int i,j,k;
int xx[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void yanchi(int ms)
{
  while(ms--)
    {
     for(i=0;i<100;i++);
    }
}
void main()
{
  while(1)
    {
      for(j=0;j<10000;j++)
        { 
          P2=xx[j/1000];//千
          LE3=0;
          yanchi(1);
          LE3=1;
          yanchi(1);
          LE3=0;  
          P2=xx[(j%1000)/100];//百
          LE2=0;
          yanchi(1);
          LE2=1;
          yanchi(1);
          LE2=0;
          P2=xx[(j%100)/10];//十
           LE1=0;
          yanchi(1);
          LE1=1;
          yanchi(1);
          LE1=0;         
          P2=xx[j%10];//個
          LE0=0;
          yanchi(1);
          LE0=1;
          yanchi(1);
          LE0=0;         
          yanchi(100);
        } 
    }
}
 
 
 
 
#include"reg51.h"
#include<intrins.h>
int i,j,k,ss;
int xx[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void yanchi(int ms)
{
  while(ms--)
    {
     for(i=0;i<100;i++);
    }
}
void main()
{
  while(1)
    {
      for(j=9900;j<10000;j++)
        {           
       
          P2=xx[j%10];//個
          P1=0X01;
          yanchi(1);      
          P1=0x00; 
   
          P2=xx[(j%100)/10];//十
          P1=0x02;       
          yanchi(1);
          P1=0x00;        
 
          P2=xx[(j%1000)/100];//百
          P1=0x04;
          yanchi(1);
          P1=0x00;
           
          
          P2=xx[j/1000];//千
          P1=0x08;
          yanchi(1);
          P1=0x00;
          
          if (j==9999)
              ss++;
          P2=xx[ss%10];//萬
          P1=0x10;
          yanchi(1);
          P1=0x00;
          P2=xx[(ss%100)/10];//十萬
          P1=0x20;
          yanchi(1);
          P1=0x00;
          P2=xx[(ss%1000)/100];//百萬
          P1=0x40;
          yanchi(1);
          P1=0x00;
          P2=xx[ss/1000];//千萬
          P1=0x80;
          yanchi(1);
          P1=0x00;
          
          yanchi(10);
          
        } 
    }
}
 
關閉窗口

相關文章