標題: 動態(tài)數(shù)碼管顯示實驗 [打印本頁]

作者: 51heix層    時間: 2020-7-7 20:05
標題: 動態(tài)數(shù)碼管顯示實驗
/*         實驗名:動態(tài)數(shù)碼管顯示實驗
*         實驗說明:8位數(shù)碼管顯示4036

*****************************/
                  #include<reg51.h>
#define GPIO_DIG P0       //段選
#define GPIO_PLACE P1    //位選
unsigned char code DIG_PLACE[] = {
0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f };   //位選控制
unsigned char code DIG_CODE[] = {0x66,0x3f,0x4f,0x7};   //4036
unsigned char DisplayDate[8];   //用來存放要顯示的8位數(shù)的值
void DigDisplay();         //動態(tài)顯示函數(shù)
//主函數(shù)
void main(void)
{     
     unsigned char i;
     for(i=0;i<8;i++)
     {
             DisplayDate[i] = DIG_CODE[i];
     }
         while(1)
         {
         DigDisplay();
         }
}
//使用數(shù)碼管顯示
void DigDisplay()
{
      unsigned char i;
          unsigned int j;

          for(i=0;i<8;i++)
          {
             GPIO_PLACE = DIG_PLACE[i];         //發(fā)送位選
                 GPIO_DIG = DisplayDate[i];     //發(fā)送段碼
                 j = 10;
                 while(j--)                          //掃描間隔時間設定
                 GPIO_DIG = 0x00;    //消隱
          }
}






歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1