#include <at89x51.h>
char K[16]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
int d=0;
void delay(a)
{
int i,j;
for(i=0;i<a;i++)
for(j=0;j<10;j++);
}
main()
{
while(1)
{P1=0Xfe;
delay(100);
if(P1==0Xee)
{d=1;}
if(P1==0Xde)
{d=2;}
if(P1==0Xbe)
{d=3;}
if(P1==0X7e)
{d=4;}
P1=0Xfd;
delay(100);
if(P1==0Xed)
{d=5;}
if(P1==0Xdd)
{d=6;}
if(P1==0Xbd)
{d=7;}
if(P1==0X7d)
{d=8;}
P1=0Xfb;
delay(100);
if(P1==0Xeb)
{d=9;}
if(P1==0Xdb)
{d=10;}
if(P1==0Xbb)
{d=11;}
if(P1==0X7b)
{d=12;}
P1=0Xf7;
delay(100);
if(P1==0Xe7)
{d=13;}
if(P1==0Xd7)
{d=14;}
if(P1==0Xb7)
{d=15;}
if(P1==0X77)
{d=16;}
P3=0xFD;P2=K[d%10];
delay(10);
P3=0xFE;P2=K[d/10];
delay(10);
}
}
|