📄 187.c
字号:
#include<reg51.h>
#include<MAX187.h>
#include<lcd1602.h>
#define Uchar unsigned char
#define Uint unsigned int
unsigned long sum; //
void delayms(unsigned int x) //delay x ms
{
unsigned char j;
while((x--)!=0 )
{ for(j=0;j<125;j++)
{ ; }
}
}
void read(void)
{ long int x;
//long float y;
long float result;
uchar temp[9];
// delayms(500);
max187(); //sum=(Adss*16+Date/16);
sum=Adss*16+Date/16; //Voltage-16 U0单位为mV
//sum=1024;
result=sum*100000;
//y=result
//y=100.0/(result*2.0);
// x=315003532;
x=(long int)result;
temp[0]=(uchar)(x/100000000);
temp[1]=(uchar)((x-temp[0]*100000000)/10000000);
temp[2]=(uchar)((x-temp[0]*100000000-temp[1]*10000000)/1000000);
temp[3]=(uchar)((x-temp[0]*100000000-temp[1]*10000000-temp[2]*1000000)/100000);
temp[4]=(uchar)((x-temp[0]*100000000-temp[1]*10000000-temp[2]*1000000-temp[3]*100000)/10000);
temp[5]=(uchar)((x-temp[0]*100000000-temp[1]*10000000-temp[2]*1000000-temp[3]*100000-temp[4]*10000)/1000);
temp[6]=(uchar)((x-temp[0]*100000000-temp[1]*10000000-temp[2]*1000000-temp[3]*100000-temp[4]*10000-temp[5]*1000)/100);
temp[7]=(uchar)((x-temp[0]*100000000-temp[1]*10000000-temp[2]*1000000-temp[3]*100000-temp[4]*10000-temp[5]*1000-temp[6]*100)/10);
temp[8]=(uchar)( x-temp[0]*100000000-temp[1]*10000000-temp[2]*1000000-temp[3]*100000-temp[4]*10000-temp[5]*1000-temp[6]*100-temp[7]*10);
clr();
load0();showchar(20,temp[0]+48);
load0();showchar(21,'.');
load0();showchar(22,temp[1]+48);
load0();showchar(23,temp[2]+48);
load0();showchar(24,temp[3]+48);
load0();showchar(25,temp[4]+48);
load0();showchar(26,temp[5]+48);
load0();showchar(27,temp[6]+48);
load0();showchar(28,temp[7]+48);
load0();showchar(29,temp[8]+48);
}
void main(void)
{ delayms(500);
load0();
display(0,table);
while(1)
{
delayms(500);
read();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -