|
源程序
#include <REG51.H>
#define uint unsigned int
#define uchar unsigned char
uchar code DIS_SEG7[]={0xf9,0x92,0xb0,0xf9,0xc0,0xa4,0xf9,0xb0};//設(shè)置學號,共陽字形碼
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++)
{//點亮數(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;
}
}
|
-
無標題1.png
(116.46 KB, 下載次數(shù): 68)
下載附件
2018-9-21 17:00 上傳
-
無標題.png
(97.39 KB, 下載次數(shù): 62)
下載附件
2018-9-21 16:59 上傳
|