#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
sbit wr=P2^6;
sbit rd=P2^7;
sbit adint=P2^5;
delay(uint z)
{
uchar w;
while(z--)
{
for(w=0;w<125;w++);
}
}
ad_star()
{
wr=1;
wr=0;
wr=1;
}
main()
{
uchar a;
while(1)
{
ad_star();
while(adint);
rd=0;
a=P0;
delay(10);
rd=1;
if(a>0&a<=20){P3=0xc0;}
if(a>20&a<=40){P3=0xf9;}
if(a>40&a<=60){P3=0xa4;}
if(a>60&a<=80){P3=0xb0;}
if(a>80&a<=100){P3=0x99;}
if(a>100&a<=120){P3=0x92;}
if(a>120&a<=140){P3=0x82;}
if(a>140&a<160){P3=0xf8;}
if(a>160&a<=180){P3=0x80;}
if(a>180&a<=200){P3=0x90;}
if(a>200&a<=220){P3=0x88;}
if(a>220&a<=240){P3=0x83;}
if(a>240&a<=255){P3=0xc6;}
}
}