资料下载地址:51单片机四路DS18B20温度检测系统代码与Proteus仿真图
1、仿真图
2、代码
void main(void)
{
uint k;
uchar number;
BEEP=1;
LCD_Initial();
//init_lcd();
writestring(0,0," Search Sensor ");
delayms(800);
number=FindDevices(Ds18b20Rom);
writestring(0,0,"Search sensors");
writeChar(7,0,number/10+'0');
writeChar(8,0,number%10+'0');
for(k=0;k<number;k++)
{
StartDs18b20(& Ds18b20Rom[k][0]);
}
delayms(800);
writestring(0,0,"A B ");
writestring(0,1,"C D ");
while(1)
{
if(Set==0)
{
for(k=0;k<number;k++)
{
StartDs18b20(& Ds18b20Rom[k][0]);
ReadDs18b20(& Ds18b20Rom[k][0]);
switch(k)
{
case 0:
TP1=TZ;tf1=tflag;
writeChar(1,0,tflag);
writeChar(2,0,TZ/100+'0');
writeChar(3,0,TZ/10%10+'0');
writeChar(4,0,TZ%10+'0');
writeChar(5,0,'.');
writeChar(6,0,TD+'0');
break;
case 1:
TP2=TZ;tf2=tflag;
writeChar(10,0,tflag);
writeChar(11,0,TZ/100+'0');
writeChar(12,0,TZ/10%10+'0');
writeChar(13,0,TZ%10+'0');
writeChar(14,0,'.');
writeChar(15,0,TD+'0');
break;
case 2:
TP3=TZ;tf3=tflag;
writeChar(1,1,tflag);
writeChar(2,1,TZ/100+'0');
writeChar(3,1,TZ/10%10+'0');
writeChar(4,1,TZ%10+'0');
writeChar(5,1,'.');
writeChar(6,1,TD+'0');
break;
case 3:
TP4=TZ;tf4=tflag;
writeChar(10,1,tflag);
writeChar(11,1,TZ/100+'0');
writeChar(12,1,TZ/10%10+'0');
writeChar(13,1,TZ%10+'0');
writeChar(14,1,'.');
writeChar(15,1,TD+'0');
break;
}
}
}
SetFun();
Alarm();
}
}
标签:仿真,Search,writeChar,writestring,DS18B20,51,number,单片机
From: https://blog.csdn.net/qq_35654286/article/details/142488560