標(biāo)題: 數(shù)碼管學(xué)號(hào)滾動(dòng)顯示的單片機(jī)程序 [打印本頁]

作者: 飛翔的企鵝1    時(shí)間: 2018-9-21 17:00
標(biāo)題: 數(shù)碼管學(xué)號(hào)滾動(dòng)顯示的單片機(jī)程序
源程序
#include <REG51.H>
#define uint unsigned int
#define uchar unsigned char
uchar code DIS_SEG7[]={0xf9,0x92,0xb0,0xf9,0xc0,0xa4,0xf9,0xb0};//設(shè)置學(xué)號(hào),共陽字形碼
uchar code DIS_BIT[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};// 8位數(shù)碼管位選
sbit k1=P1^0;
sbit k2=P1^1;
void delay1ms(uint i)
{
  uint j;
  while(i--)
     for(j=0;j<110;j++);
}
void main(void)
{
   uchar cnt,ttt;
   uchar DISP[]={0,1,2,3,4,5,6,7};
   while(1)
   {
       for(ttt=0;ttt<100;ttt++)
    for(cnt=0;cnt<8;cnt++)
    {//點(diǎn)亮數(shù)碼館0-7
        P2=0;
     P0=DIS_SEG7[DISP[cnt]];
     P2=~DIS_BIT[cnt];
     if(k1==1&&k2==1)
         delay1ms(1);
      else {
       if(k1==0&&k2==1)
                delay1ms(2);
       else{
           if(k1==1&&k2==0)
                      delay1ms(3);
       else{
                           if(k1==0&&k2==0)
                           delay1ms(4);
         }
         }
                       }
  }
ttt=DISP[0];
DISP[0]=DISP[1];
DISP[1]=DISP[2];
DISP[2]=DISP[3];
DISP[3]=DISP[4];
DISP[4]=DISP[5];
  DISP[5]=DISP[6];
   DISP[6]=DISP[7];
DISP[7]=ttt;
}
}


無標(biāo)題1.png (116.46 KB, 下載次數(shù): 68)

無標(biāo)題1.png

無標(biāo)題.png (97.39 KB, 下載次數(shù): 62)

無標(biāo)題.png

作者: asdefg    時(shí)間: 2020-4-26 16:54
if(k1==1&&k2==1)
         delay1ms(1);
      else {
       if(k1==0&&k2==1)
                delay1ms(2);
       else{
           if(k1==1&&k2==0)
                      delay1ms(3);
       else{
                           if(k1==0&&k2==0)
                           delay1ms(4);
         }
         }
                       }

這個(gè)有什么用啊




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