📄 main.c
字号:
#include"reg51.h"
#include"address.h"
#include"2-16.h"
#include"18b20.h"
#define uint unsigned int
#define uchar unsigned char
uchar code tab[]={'0','1','2','3','4','5','6','7','8','9'};
void main()
{
uchar i,high,tem[9],temp[11];//temp[11]是LCD显示的缓冲区
uint low;
temp[4]='.';
temp[9]=0xDf;
temp[10]='C';
initlcd();
TemperatuerResult() ;
while(1)
{
get(); //把温度放进变量Temperature中
if(Temperature&0xf800)temp[0]='-';else temp[0]='+';
Temperature&=0x07ff;
high=Temperature>>4;
low=Temperature&0x0f;
low*=625;
tem[1]=high/100;
high=high%100;
tem[2]=high/10;
tem[3]=high%10;
tem[5]=low/1000;
low%=1000;
tem[6]=low/100;
low%=100;
tem[7]=low/10;
tem[8]=low%10;
for(i=1;i!=9;i++){if(i==4)continue ;temp[i]=tab[tem[i]];}
printf(temp,11);
LEDDATA=0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -