|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2009-11-19 14:18:42
|
显示全部楼层
#include <regx51.h>
unsigned char code dispbit[]={0xfe,0xfd,0xfb,0xf7};
unsigned char code dispcode[]={0x3f,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f,0x00};
long int dispbuf[4]={0,0,0,0} ;
void delay(int n)
{int i,j,k;
for(i=0;i<=n;i++)
{for(j=0;j<=1;j++)
{for(k=0;k<=254;k++);}}}
sbit ST=P3^5;
long int getdata;
void main()
{
int i;
while(1)
{
ST=0;
ST=1;
//delay(1);
ST=0;
while(P3_7==0)
{P3_6=0;
P3_6=1;}
getdata=P0;
getdata=getdata*1200; //标准值
getdata=getdata/255;
dispbuf[3]=getdata/1000;
dispbuf[2]=getdata%1000/100;
dispbuf[1]=getdata%100/10;
dispbuf[0]=getdata%10;
for(i=0;i<=3;i++)
{P1=dispcode[dispbuf];
P2=dispbit;
if(i==2)
P1_7=1;
delay(1);}
}}
这是我的程序 |
|