单片机多机多点温控系统从机模块

单片机多机多点温控系统从机模块

ID:39554451

大小:78.83 KB

页数:12页

时间:2019-07-06

单片机多机多点温控系统从机模块_第1页
单片机多机多点温控系统从机模块_第2页
单片机多机多点温控系统从机模块_第3页
单片机多机多点温控系统从机模块_第4页
单片机多机多点温控系统从机模块_第5页
资源描述:

《单片机多机多点温控系统从机模块》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、//DS从机程序#include#include12#defineucharunsignedchar#defineuintunsignedint#defineSLAVE0x01#defineBN6sbitLCD_RS=P2^5;/*定义LCD控制端口*/sbitLCD_RW=P2^6;sbitLCD_EN=P2^7;sbitDS1=P1^0;sbitDS2=P1^1;sbitkey3=P3^5;sbittem=P3^3;sbitwin=P3^4;sbitkey1=P3^6;s

2、bitkey2=P3^7;uinttemp1,temp2,tempH,tempL;//variableoftemperatureucharflag1,aa,we;ucharA1,A2,A3,A4,B1,B2,B3,B4;//signoftheresultpositiveornegativeuchardis1[16]={76,45,84,'0','0','.','0',32,32,72,45,84,'0','0','.','0'};uchardis2[16]={48,49,32,'0','0','.','0',32,

3、32,48,50,32,'0','0','.','0'};ucharcodetab[]={'0','1','2','3','4','5','6','7','8','9'};uchartrbuf[6];bittready;bitrready;voidstr(void);voidsre(void);voiddelay(intms){inti;while(ms--){for(i=0;i<250;i++){_nop_();_nop_();_nop_();_nop_();}}}/***********************

4、********************************************//**//*检查LCD忙状态*//*lcd_busy为1时,忙,等待。lcd-busy为0时,闲,可写指令与数据。*//**//*******************************************************************/bitlcd_busy(){bitresult;LCD_RS=0;12LCD_RW=1;LCD_EN=1;_nop_();_nop_();_nop_();_nop_(

5、);result=(bit)(P0&0x80);LCD_EN=0;returnresult;}/*******************************************************************//**//*写指令数据到LCD*//*RS=L,RW=L,E=高脉冲,D0-D7=指令码。*//**//*******************************************************************/voidlcd_wcmd(ucharcmd){w

6、hile(lcd_busy());LCD_RS=0;LCD_RW=0;LCD_EN=0;_nop_();_nop_();P0=cmd;_nop_();_nop_();_nop_();_nop_();LCD_EN=1;_nop_();_nop_();_nop_();_nop_();LCD_EN=0;}/*******************************************************************//**//*写显示数据到LCD*//*RS=H,RW=L,E=高脉冲,D0-D7=

7、数据。*//**//*******************************************************************/voidlcd_wdat(uchardat){while(lcd_busy());LCD_RS=1;LCD_RW=0;LCD_EN=0;P0=dat;_nop_();12_nop_();_nop_();_nop_();LCD_EN=1;_nop_();_nop_();_nop_();_nop_();LCD_EN=0;}/*********************

8、**********************************************//**//*设定显示位置*//**//*******************************************************************/voidlcd_pos(ucharpos){lcd_wcmd(pos

9、0x80);//数据指

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。