标题:
单线挂载多路ds18b20的单片机源程序
[打印本页]
作者:
xiuyueyuan2013
时间:
2018-1-13 16:01
标题:
单线挂载多路ds18b20的单片机源程序
单线挂载多个ds18b20源码,一份读取单个ds18b20 rom,一份挂载多个ds18b20的,程序里只挂载了两个,修改一下可以挂载多个,lcd1602显示读取的温度
0.jpg
(9.82 KB, 下载次数: 58)
下载附件
2018-1-13 18:27 上传
单片机源程序如下:
#include"ds18b20.h"
uchar rom[2][8]={
{0x28,0x6e,0xe4,0x4d,0x06,0x00,0x00,0xa7},
{0x28,0xff,0xa3,0xfd,0xa4,0x16,0x05,0xc8}};
int temp[2];
void dsinit()
{
uchar i;
dsport=0;
i=90;
while(i--);
dsport=1;
i++;
i++;
while(dsport);
while(!dsport);
i++;
i++;
}
void dssendbit(bit x)
{
uchar i;
dsport=0;
i++;
i++;
dsport=x;
i=9;
while(i--);
dsport=1;
i++;
i++;
}
bit dsreadbit()
{
uchar i;
bit x=0;
dsport=0;
i++;
i++;
dsport=1;
i++;
i++;
if(dsport)
{
x=1;
}
i=9;
while(i--);
return x;
}
void dssendbyte(uchar byte)
{
uchar n;
for(n=0;n<8;n++)
{
dssendbit(byte&0x01);
byte>>=1;
}
}
uchar dsreadbyte()
{
uchar n,dat;
for(n=0;n<8;n++)
{
dat>>=1;
if(dsreadbit())
{
dat|=0x80;
}
}
return dat;
}
/*void dsconvert()
{
uchar i;
dsinit();
dssendbyte(0xcc);
dssendbyte(0x44);
i++;
i++;
while(!dsport);
i++;
i++;
}
void dsreadtempcom()
{
dsinit();
dssendbyte(0xcc);
dssendbyte(0xbe);
}*/
void dsreadtemp()
{
uchar tml,tmh,n,v,i;
for(n=0;n<2;n++)
{
dsinit();
dssendbyte(0x55);
for(v=0;v<8;v++)
{
dssendbyte(rom[n][v]);
}
dssendbyte(0x44);
i++;
i++;
……………………
…………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
单线挂载多路ds18b20.zip
(75.52 KB, 下载次数: 70)
2018-1-13 16:00 上传
点击文件名下载附件
下载积分: 黑币 -5
作者:
rrqxx
时间:
2018-1-13 20:02
这个可以有,下载来看看。
作者:
xiuyueyuan2013
时间:
2018-1-14 02:57
本帖最后由 xiuyueyuan2013 于 2018-1-14 13:23 编辑
那个搜索警报的命令0xec怎么用,高手指导下哈,自己没看懂pdf说明
作者:
2633664670
时间:
2018-11-16 20:53
改了端口,但为什么没法显示序列号啊 rom
作者:
雨洁
时间:
2019-9-9 08:57
感谢楼主
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1