📄 ds18b20智能温度控制器(汇编与c语言).htm
字号:
i)<BR>{<BR> while(i--);<BR>
<BR>}<BR>//初始化函数<BR>Init_DS18B20(void)<BR>{<BR> unsigned char
x=0;<BR> DQ = 1; //DQ复位<BR> delay(8);
//稍做延时<BR> DQ = 0; //单片机将DQ拉低<BR> delay(80);
//精确延时 大于 480us<BR> DQ = 1;
//拉高总线<BR> delay(14);<BR> x=DQ;
//稍做延时后 如果x=0则初始化成功
x=1则初始化失败<BR> delay(20);<BR>}<BR>//读一个字节<BR>ReadOneChar(void)<BR>{<BR>unsigned
char i=0;<BR>unsigned char dat = 0;<BR>for
(i=8;i>0;i--)<BR> {<BR> DQ = 0; // 给脉冲信号<BR>
dat>>=1;<BR> DQ = 1; // 给脉冲信号<BR> if(DQ)<BR>
dat|=0x80;<BR>
delay(4);<BR> }<BR> return(dat);<BR>}<BR>//写一个字节<BR>WriteOneChar(unsigned
char dat)<BR>{<BR> unsigned char i=0;<BR> for (i=8; i>0;
i--)<BR> {<BR> DQ = 0;<BR> DQ = dat&0x01;<BR>
delay(5);<BR> DQ = 1;<BR>
dat>>=1;<BR> }<BR>delay(4);<BR>}<BR>//读取温度<BR>ReadTemperature(void)<BR>{<BR>unsigned
char a=0;<BR>unsigned char b=0;<BR>unsigned char
t=0;<BR>Init_DS18B20();<BR>WriteOneChar(0xCC); //
跳过读序号列号的操作<BR>WriteOneChar(0x44); //
启动温度转换<BR>Init_DS18B20();<BR>WriteOneChar(0xCC);
//跳过读序号列号的操作<BR>WriteOneChar(0xBE); //读取温度寄存器等(共可读9个寄存器)
前两个就是温度<BR>a=ReadOneChar();
//读取温度值低位<BR>b=ReadOneChar();
//读取温度值高位<BR>a=a>>4;
//低位右移4位,舍弃小数部分<BR>t=b<<4;
//高位左移4位,舍弃符号位<BR>t=t|a;
<BR>return(t);<BR>}<BR>void display_tempmain(unsigned char
i)
//主程序温度显示函数<BR>{<BR> P0=tab[i/10];<BR> shi=0;<BR>
ge=1;<BR> delay(1000);<BR> P0=tab[i%10];<BR>
shi=1;<BR> ge=0; <BR>}<BR>void main(void)<BR>{unsigned int
temp;</P>
<P>while(1)
//主循环<BR> {
temp=ReadTemperature();<BR>
display_tempmain(temp);<BR>
<BR> } <BR>}</P>
<P>高清视频:<A href="http://edu.mcu99.com/down/1820.mpg"><FONT
color=#ff0000>下载</FONT></A>观看</P>
<P>
<OBJECT id=MediaPlayer1
codeBase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701standby=Loading
type=application/x-oleobject height=288 width=352
classid=CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6 VIEWASTEXT><PARAM NAME="URL" VALUE="http://edu.mcu99.com/down/1820.mpg"><PARAM NAME="rate" VALUE="1"><PARAM NAME="balance" VALUE="0"><PARAM NAME="currentPosition" VALUE="-1"><PARAM NAME="defaultFrame" VALUE=""><PARAM NAME="playCount" VALUE="1"><PARAM NAME="autoStart" VALUE="-1"><PARAM NAME="currentMarker" VALUE="0"><PARAM NAME="invokeURLs" VALUE="-1"><PARAM NAME="baseURL" VALUE=""><PARAM NAME="volume" VALUE="70"><PARAM NAME="mute" VALUE="0"><PARAM NAME="uiMode" VALUE="full"><PARAM NAME="stretchToFit" VALUE="0"><PARAM NAME="windowlessVideo" VALUE="0"><PARAM NAME="enabled" VALUE="-1"><PARAM NAME="enableContextMenu" VALUE="-1"><PARAM NAME="fullScreen" VALUE="0"><PARAM NAME="SAMIStyle" VALUE=""><PARAM NAME="SAMILang" VALUE=""><PARAM NAME="SAMIFilename" VALUE=""><PARAM NAME="captioningID" VALUE=""></OBJECT><BR>下图为正在用启点开发板做温度传感器18B20的实验,汇编与C程序均通过测试.</P>
<P></P>
<P><IMG onmousewheel="return bbimg(this)" height=946
src="DS18B20智能温度控制器(汇编与C语言).files/20051101090654348.jpg" width=995
onload=javascript:resizepic(this) border=0></P></TD></TR>
<TR>
<TD class=left_tdbgall align=right
colSpan=2>本站教程录入:江在流 责任编辑:江在流 </TD></TR>
<TR>
<TD width=5></TD>
<TD width=752>
<LI>上一篇本站教程: <A class=LinkPrevArticle
title="本站教程标题:AT24C02串行E2PROM的读写 作 者:姜再留 更新时间:2005-3-14 21:44:49"
href="http://www.mcu99.com/jiaocheng/yuanchuang/200503/522.html">AT24C02串行E2PROM的读写</A><BR>
<LI>下一篇本站教程: <A class=LinkNextArticle
title="本站教程标题:认识启点开发板V1.0 作 者:江在流 更新时间:2005-3-30 21:26:37"
href="http://www.mcu99.com/jiaocheng/yuanchuang/200503/562.html">认识启点开发板V1.0</A></LI></TD></TR>
<TR class=left_tdbgall align=right>
<TD colSpan=2>【<A
href="http://www.mcu99.com/jiaocheng/Comment.asp?ArticleID=523"
target=_blank>发表评论</A>】【<A
href="http://www.mcu99.com/User/User_Favorite.asp?Action=Add&ChannelID=10&InfoID=523"
target=_blank>加入收藏</A>】【<A
href="http://www.mcu99.com/jiaocheng/SendMail.asp?ArticleID=523"
target=_blank>告诉好友</A>】【<A
href="http://www.mcu99.com/jiaocheng/Print.asp?ArticleID=523"
target=_blank>打印此文</A>】【<A href="javascript:window.close();">关闭窗口</A>】
</TD></TR></TBODY></TABLE>
<TABLE class=center_tdbgall cellSpacing=0 cellPadding=0 width=760 align=center
border=0>
<TBODY>
<TR>
<TD class=main_shadow></TD></TR></TBODY></TABLE><!--文章显示代码结束--><!--最新热点、最新推荐、相关文章代码开始-->
<TABLE class=center_tdbgall style="WORD-BREAK: break-all" cellSpacing=0
cellPadding=0 width=760 align=center border=0>
<TBODY>
<TR>
<TD class=main_title_282 width="33%"><B>最新热点</B></TD>
<TD width=5 rowSpan=2></TD>
<TD class=main_title_282 width="33%"><B>最新推荐</B></TD>
<TD width=5 rowSpan=2></TD>
<TD class=main_title_282 width="33%"><B>相关本站教程</B></TD></TR>
<TR>
<TD class=main_tdbg_760 vAlign=top height=100>
<SCRIPT language=javascript
src="DS18B20智能温度控制器(汇编与C语言).files/Article_Hot3.js"></SCRIPT>
</TD>
<TD class=main_tdbg_760 vAlign=top width="33%">
<SCRIPT language=javascript
src="DS18B20智能温度控制器(汇编与C语言).files/Article_Elite3.js"></SCRIPT>
</TD>
<TD class=main_tdbg_760 vAlign=top width="33%">
<LI><A class=LinkArticleCorrelative
title="本站教程标题:AT24C02串行E2PROM的读写 作 者:姜再留 更新时间:2005-3-14 21:44:49"
href="http://www.mcu99.com/jiaocheng/yuanchuang/200503/522.html">AT24C02串行E2PROM的读写</A><BR>
<LI><A class=LinkArticleCorrelative
title="本站教程标题:红外线遥控器解码程序 作 者:姜再留 更新时间:2005-3-14 21:40:06"
href="http://www.mcu99.com/jiaocheng/yuanchuang/200503/521.html">红外线遥控器解码程序</A><BR>
<LI><A class=LinkArticleCorrelative
title="本站教程标题:红外线遥控器声光测试器 作 者:姜再留 更新时间:2005-3-14 21:36:04"
href="http://www.mcu99.com/jiaocheng/yuanchuang/200503/520.html">红外线遥控器声光测试器</A><BR>
<LI><A class=LinkArticleCorrelative
title="本站教程标题:单片机和PC机串口通讯试验 作 者:姜再留 更新时间:2005-3-14 21:30:51"
href="http://www.mcu99.com/jiaocheng/yuanchuang/200503/519.html">单片机和PC机串口通讯试验</A><BR>
<LI><A class=LinkArticleCorrelative
title="本站教程标题:单片机倒计时定时器 作 者:姜再留 更新时间:2005-3-14 21:00:15"
href="http://www.mcu99.com/jiaocheng/yuanchuang/200503/518.html">单片机倒计时定时器</A><BR>
<LI><A class=LinkArticleCorrelative
title="本站教程标题:单片机演奏音乐实验 作 者:姜再留 更新时间:2005-3-14 19:39:51"
href="http://www.mcu99.com/jiaocheng/yuanchuang/200503/517.html">单片机演奏音乐实验</A><BR>
<LI><A class=LinkArticleCorrelative
title="本站教程标题:启点单片机实验板教程三:数码管显示 作 者:姜再留 更新时间:2004-10-3 16:48:57"
href="http://www.mcu99.com/jiaocheng/yuanchuang/200410/306.html">启点单片机实验板教程三:数</A><BR></LI></TD></TR></TBODY></TABLE>
<TABLE class=center_tdbgall cellSpacing=0 cellPadding=0 width=760 align=center
border=0>
<TBODY>
<TR>
<TD class=main_shadow></TD></TR></TBODY></TABLE><!--最新热点、最新推荐、相关文章代码结束--><!--网友评论代码开始-->
<TABLE class=center_tdbgall style="WORD-BREAK: break-all" cellSpacing=0
cellPadding=0 width=760 align=center border=0>
<TBODY>
<TR>
<TD class=left_tdbgall height=25><STRONG><IMG height=16
src="DS18B20智能温度控制器(汇编与C语言).files/TEAM.gif" width=16 align=absMiddle>
网友评论:</STRONG>(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)</TD></TR>
<TR>
<TD>
<SCRIPT language=javascript src=""></SCRIPT>
</TD></TR></TBODY></TABLE>
<TABLE class=center_tdbgall cellSpacing=0 cellPadding=0 width=760 align=center
border=0>
<TBODY>
<TR>
<TD class=main_shadow></TD></TR></TBODY></TABLE><!--网友评论代码结束--><!-- ********网页中部代码结束******** --><!-- ********网页底部代码开始******** -->
<TABLE class=Bottom_tdbgall style="WORD-BREAK: break-all" cellSpacing=0
cellPadding=0 width=760 align=center border=0>
<TBODY>
<TR align=middle>
<TD class=Bottom_Adminlogo colSpan=2><A
href="http://www.mcu99.com/sitemap.htm">网站导航</A>| <A class=Bottom
onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.mcu99.com/');"
href="http://www.mcu99.com/jiaocheng/yuanchuang/200503/523.html#">设为首页</A>
| <A class=Bottom
href="javascript:window.external.addFavorite('http://www.mcu99.com/','单片机启点网');">加入收藏</A>
| <A class=Bottom href="mailto:mcu99@mcu99.com">联系站长</A> | <A class=Bottom
href="http://www.mcu99.com/FriendSite/Index.asp" target=_blank>友情链接</A> |
<A class=Bottom href="http://www.mcu99.com/Copyright.asp"
target=_blank>版权申明</A> | <A class=Bottom
href="http://www.mcu99.com/Admin/Admin_Index.asp"
target=_blank>管理登录</A> | </TD></TR>
<TR class=Bottom_Copyright>
<TD width="20%"> </TD>
<TD width="80%">站长:<A href="mailto:mcu99@mcu99.com">江在流</A>
</TD></TR></TBODY></TABLE><!-- ********网页底部代码结束******** -->
<SCRIPT language=javascript src="DS18B20智能温度控制器(汇编与C语言).files/1.js"></SCRIPT>
<SCRIPT language=javascript src="DS18B20智能温度控制器(汇编与C语言).files/2.js"></SCRIPT>
<SCRIPT language=JavaScript src="DS18B20智能温度控制器(汇编与C语言).files/click.htm"
type=text/javascript>
</SCRIPT>
<!-- Powered by: PowerEasy 2005 --></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -