#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar tab[]={0XC0,0XF9,0XA4,0XB0,0X99,0X92,0X82,0XF8,0X80,0X90};
sbit clock=P0^3;
sbit start=P0^2;
sbit oe=P0^0;
sbit eoc=P0^1;
sbit p4=P3^0;
sbit p5=P3^1;
sbit p6=P3^2;
//sbit p27=P2^7;
sbit sound=P3^7;
int count,a=0;
uchar bai,shi,ge;
void delay(uint c){
uchar count;
while(c--){
for(count=0;count<120;count++);
}
}
void convert(){
start=1;
delay(1);
start=0;
while(!eoc);
oe=1;
count=P1;
count=count*1.960787431372;
}
void display(){
bai=count/100;
shi=count%100/10;
ge=count%{bfb}10;
//p4=1;
//p27=0;
//delay(1);
//p4=0;
p4=1;
P2=tab[bai];
delay(1);
p4=0;
p5=1;
P2=tab[shi];
delay(1);
p5=0;
p6=1;
P2=tab[ge];
delay(1);
p6=0;
}
void main(){
TMOD=0X11;
TH0=(65536-20)/256;
TL0=(65536-20)%256;
TH1=(65536-3000)/256;
TL1=(65536-3000)%256;
EA=1;
ET0=1;
TR0=1;
ET1=1;
TR1=0;
start=0;
oe=0;
eoc=1;
//p27=0;
while(1){
convert();
display();
if(bai==5){
TR1=1;
}
else TR1=0;
}
}
void t0()interrupt 1{
TH0=(65536-20)/256;
TL0=(65536-20)%256;
clock=~clock;
}
void t1()interrupt 3{
TH1=(65536-3000)/256;
TL1=(65536-3000)%256;
sound=~sound;
}