内容发布更新时间 : 2024/12/26 9:41:06星期一 下面是文章的全部内容请认真阅读。
电路原理图
程序
1.main.c
#include
void main() {
LcdInit();
LcdWriteCom(0xc7); LcdWriteData('C'); while(1) { if(K1==0) {
Delay1ms(500); if(K1==0); th++; } if(K2==0) {
Delay1ms(500); if(K2==0); th--; } if(K3==0) {
Delay1ms(500);
if(K3==0); tl++; } if(K4==0) {
Delay1ms(500); if(K4==0); tl--; }
LcdDisplay(Ds18b20ReadTemp()); }
}
void LcdDisplay(int temp) {
int i,tt,rr,mm;
unsigned char datas[] = {0, 0, 0, 0},datas2[] = {0, 0, 0};
float tp;
if(temp< 0)
{ LcdWriteCom(0xc0);
LcdWriteData('-');
0},datas1[] = {0, 0,
i=1;
temp=temp-1; temp=~temp; tp=temp;
temp=tp*0.0625*10+0.5; mm=-temp;
} else {
LcdWriteCom(0xc0); LcdWriteData('+'); }
datas[0] = temp / 1000; tp=temp;
temp=tp*0.0625*10+0.5; mm=temp;
datas[1] = temp % 1000 / 100; datas[2] = temp % 100 / 10; datas[3] = temp% 10; if(th < 0)
{
LcdWriteCom(0x89);
LcdWriteData('-'); tt=-th;
} else {
LcdWriteCom(0x89); LcdWriteData('+'); }
datas1[0] = tt / 100; datas1[1] = tt% 100 / 10; datas1[2] = tt % 10; LcdWriteCom(0x87); LcdWriteData('H'); LcdWriteCom(0x88); LcdWriteData(':'); LcdWriteCom(0x8a);
tt=th;
LcdWriteData('0'+datas1[0]); LcdWriteCom(0x8b);
LcdWriteData('0'+datas1[1]); LcdWriteCom(0x8c);
LcdWriteData('0'+datas1[2]);