📄 3.c
字号:
//void delay(int i) //延时
//void wcmd(uchar c) //写控制字
//void showchar(uchar pos,uchar c) //显示单个字符(在pos位置上)
//void display(uchar pos,uchar *dispbuf) //显示字符串(在pos位置上,以`结束)
//void load0() //显示初始化(每次显示前必用,否则结果失真)
//void loadchar(uchar *str) //加载字符
//void clr() //清屏
#include <REG51.H>
#include <string.h>
#define uint unsigned int
#define uchar unsigned char
extern uint LM331(void);
uchar temp[9];
long int result;
uint ppt=0;
char code table[]={"THE RESULT IS\0"};
void read(void);
#include<1602.h>
void read(void)
{ long int x;
long float y;
result=LM331()+ppt*65536;
y=100.0/(result*2.0);
//x=315003532;
x=(long int)(y*10000);
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();
if(temp[0]!=0){load0();showchar(20,temp[0]+48);}else{;}
if(temp[1]!=0){load0();showchar(21,temp[1]+48);}else{;}
if(temp[2]!=0){load0();showchar(22,temp[2]+48);}else{;}
if(temp[3]!=0){load0();showchar(23,temp[3]+48);}else{;}
if(temp[4]!=0){load0();showchar(24,temp[4]+48);}else{;}
if(temp[5]!=0){load0();showchar(25,temp[5]+48);}else{;}
if(temp[6]!=0){load0();showchar(26,temp[6]+48);}else{;}
if(temp[7]!=0){load0();showchar(27,temp[7]+48);}else{;}
load0();showchar(28,temp[8]+48);
ppt=0;
}
main()
{
while(1)
{//jianpan();
read();
delay1s();
}
}void time1_int(void) interrupt 1
{
ppt++;
TH0=0X00;TL0=0X00;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -