|
#include<reg51.h>
#include"lcd.h"
#include"temp.h"
uchar CNCHAR[6] = "攝氏度";
void LcdDisplay(int);
void UsartConfiguration();
void main()
{
UsartConfiguration();
LcdInit();
LcdWriteCom(0x88);·
LcdWriteData('C');
while(1)
{
LcdDisplay(Ds18b20ReadTemp());
// Delay1ms(1000);
}
}
void LcdDisplay(int temp)
{
unsigned char i, datas[] = {0, 0, 0, 0, 0}
float tp;
if(temp< 0)
{
LcdWriteCom(0x80);
SBUF='-'
while(!TI);
TI=0;
LcdWriteData('-');
temp=temp-1;
temp=~temp;
tp=temp;
temp=tp*0.0625*100+0.5;
}
else
{
LcdWriteCom(0x80);
LcdWriteData('+');
SBUF='+'
while(!TI);
tp=temp;
temp=tp*0.0625*100+0.5;
}
datas[0] = temp / 10000;
datas[1] = temp % 10000 / 1000;
datas[2] = temp % 1000 / 100;
datas[3] = temp % 100 / 10;
datas[4] = temp % 10;
LcdWriteCom(0x82);
LcdWriteData('0'+datas[0])
SBUF = '0'+datas[0];
while (!TI);
TI = 0;
LcdWriteCom(0x83);
LcdWriteData('0'+datas[1]);
SBUF = '0'+datas[1]
while (!TI);
TI = 0;
LcdWriteCom(0x84);
LcdWriteData('0'+datas[2]);
SBUF = '0'+datas[2]
while (!TI);
LcdWriteCom(0x85);
LcdWriteData('.');
SBUF = '.'
while (!TI);
TI = 0;
|
-
-
LCD顯示溫度+串口接收溫度.zip
2021-5-7 22:53 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
19.22 KB, 下載次數: 21, 下載積分: 黑幣 -5
|