#include<reg52.h>
unsigned char code dispbitcode[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char dispbuf[4];
unsigned int i;
unsigned int j;
unsigned char getdata,getdata1;
unsigned int temp;
unsigned int temp1;
unsigned char count;
unsigned char d;
sbit ST=P3^0;
sbit OE=P3^1;
sbit EOC=P3^2;
sbit CLK=P3^3;
sbit P34=P3^4;
sbit P35=P3^5;
sbit P36=P3^6;
sbit P17=P1^7;
void TimeInitial();
void Delay(unsigned int i);
void TimeInitial()
{ TMOD=0x10;
TH1=(65536-200)/256;
TL1=(65536-200)%256;
EA=1;
ET1=1;
TR1=1;
}
void Delay(unsigned int i)
{
unsigned int j;
for(;i>0;i--)
{
for(j=0;j<125;j++)
{;}
}
}
void Display()
{
P1=dispbitcode[dispbuf[3]];
P2=0xfe;
Delay(2);
P1=0x00;
P1=dispbitcode[dispbuf[2]];
P17=1;
P2=0xfd;
Delay(2);
P1=0x00;
P1=dispbitcode[dispbuf[1]];
P2=0xfb;
Delay(2);
P1=0x00;
P1=dispbitcode[dispbuf[0]];
P2=0xf7;
Delay(2);
P1=dispbitcode[dispbuf[3]];
P2=0xef;
Delay(2);
P1=0x00;
P1=dispbitcode[dispbuf[2]];
P17=1;
P2=0xdf;
Delay(2);
P1=0x00;
P1=dispbitcode[dispbuf[1]];
P2=0xbf;
Delay(2);
P1=0x00;
P1=dispbitcode[dispbuf[0]];
P2=0x7f;
Delay(2);/*
P1=0x00;
P1=dispbitcode[0];
P2=0xef;
Delay(2);
P1=0x00;
P1=dispbitcode[0];
P17=1;
P2=0xdf;
P1=0x00;
P1=dispbitcode[0];
P2=0xbf;
Delay(2);
P1=0x00;
P1=dispbitcode[0];
P2=0x7f;
Delay(2);*/
P1=0x00;
}
void main()
{
TimeInitial();
while(1)
{
P34=0;
P35=0;
P36=0;
ST=0;
OE=0;
ST=1;
ST=0;
while(EOC==0){
OE=1;
getdata=P0;
OE=0;
temp=getdata*1.0/255*500;}
P34=1;
P35=0;
P36=0;
ST=0;
OE=0;
ST=1;
ST=0;
while(EOC==0){
OE=1;
getdata1=P0;
OE=0;
temp1=getdata1*1.0/255*500;}
dispbuf[0]=temp%10;
dispbuf[1]=temp/10%10;
dispbuf[2]=temp/100%10;
dispbuf[3]=temp/1000;
dispbuf[4]=temp1%10;
dispbuf[5]=temp1/10%10;
dispbuf[6]=temp1/100%10;
dispbuf[7]=temp1/1000;
Display();
}
}
void t1(void) interrupt 3 using 0
{
TH1=(65536-200)/256;
TL1=(65536-200)%256;
CLK=~CLK;
}
一个为理想不懈前进的人,一个永不言败人!
http://shop57496282.taobao.com/
欢迎光临网上店铺!