#include<reg51.h>
sbit key=P3;
unsigned char ii,i,j,k,m,n;
unsigned char jiann[]={0xee,0xde,0xbe,0x7e,0xed,0xdd,0xbd,0x7d,0xeb,0xdb,0xbb,0x7b,0xe7,0xd7,0xb7,0x77};
unsigned char shu[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//12òõêyÂë1ü
unsigned char kong[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};//¿ØÖƶ˿ú
void delay(unsigned int z)
{
while(z--);
}
jian(ii)
{
key=0x0f;//行列翻转法
if(key!=0x0f)
{
i=key;
delay(10);
if(key==i)
key=0xf0;
j=key;
k=i|j;
for(ii=0;ii<16;ii++)
{
if(k=jiann[ii])
{
P3=0xf0;
while(P3!=0xf0);
delay(10);
while(P3!=0xf0);
return(ii);
}
}
return(0xff);
}
return(0xff);
}
else return(0xff);
}
void main()
{
while(1)
{
jian(ii);
n=ii;
P1=shu[n/10];//两个共阴数码管显示
P2=shu[n%10];
}
}
|