C语言原程序:
#include
unsigned char code dispbitcode[]={0x77,0xbb,0xdd,0xee}; unsigned char code
dispcode[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00}; unsigned char dispbuf[8]={0,0,0,0,0,0,0,0}; unsigned char dispcount=0,flag; unsigned char getdata; unsigned int temp; unsigned char i,j,k; sbit ST=P3^6; sbit OE=P3^7; sbit EOC=P3^0; sbit DA=P3^5; //sbit DB=P3^4; void main(void) {
while(1) {
ST=1; ST=0;
ST=1; if(EOC==1) {
OE=0; getdata=P1; OE=1;
temp=getdata; temp=temp*100; if(DA==1)
{temp=temp/51; temp=temp*4;} else
{temp=temp/51;} dispbuf[0]=0;
dispbuf[1]=0; dispbuf[2]=0; dispbuf[3]=0; dispbuf[4]=0; dispbuf[5]=0; dispbuf[6]=0; dispbuf[7]=0; i=0;
while(temp/10)
{ dispbuf[i]=temp; temp=temp/10; i++; }
dispbuf[i]=temp; for(k=0;k<=3;k++)
{ P0=dispcode[dispbuf[k]]; P2=dispbitcode[k]; if(k==2)
P0=P0 | 0x80; for(j=0;j<=110;j++) {} } }}}

