智能温室恒温控制系统C语言程序(共22页).doc
《智能温室恒温控制系统C语言程序(共22页).doc》由会员分享,可在线阅读,更多相关《智能温室恒温控制系统C语言程序(共22页).doc(22页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精选优质文档-倾情为你奉上程序清单:#include #include #include #define uchar unsigned charsbit TMDAT = P14;/两个DS18B20的I/O口sbit TMDAT1 = P15;sbit CS=P10;sbit CLK=P11;sbit DIO=P12;sbit KEY=P13;sbit HEAT=P17;sbit COLD=P33;sbit HEAT1=P16;sbit COLD1=P32;sbit ALARM=P36;int num; /保存输入的数字 int key=7; /保存数码管号int qiehuan=0; /控制
2、屏幕显示温度或者参数int choose=0; /保存正在使用的DS18B20号int max1=23; /一号通道的报警上下限值int min1=5;int upper1=22; /一号通道的预定温度值int lower1=18; int max2=23; /二号通道的报警上下限值int min2=5;int upper2=22; /二号通道的预定温度值int lower2=18; unsigned char buffer116=0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f;/控
3、制符,用于显示不带小数点的数字unsigned char buffer216=0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f;/控制符,用于显示带小数点的数字unsigned char turn8=0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87;/控制符,用于选定数码管号unsigned int result,result1;/保存十六进制的温度值unsigned char a,b;uchar data rebuf,sebuf;uchar bdata
4、com_data;sbit mos_bit=com_data7;sbit low_bit=com_data0;void send(uchar sebuf);void delay_50us();void receive();void reset();void dmsec (unsigned int count);void tmreset (void);void tmstart (void);void tmreset1 (void);void tmstart1 (void);void fuzhi(void);/用于修改参数值void xianshi(void);/将修改的参数值显示unsigned
5、 char tmrtemp (void);unsigned char tmrtemp1 (void);main()unsigned int zhengshu,dot; unsigned char temperature;unsigned int symbol;int shiwei; int gewei;unsigned int zhengshu1,dot1; unsigned char temperature1;unsigned int symbol1;int shiwei1; int gewei1; while(1) if(choose=0) /通道一工作dmsec(1);tmstart (
6、); dmsec(1000);tmrtemp (); reset(); if(result0xf800) /将通道一的温度转换为十进制 symbol=1; result=result+1;zhengshu=result/16;dot=result&0x000f;dot=(dot*10)/16; shiwei=(zhengshu/10); gewei=(zhengshu%10); temperature=zhengshu+dot*0.1; /通道一的十进制温度 if(temperatureupper1) /通道一温度控制 COLD=1; HEAT=0; /超过预定温度的上限,启动小风扇 else
7、 if(temperaturemax1|temperature0xf800) /将通道二的温度转换为十进制 symbol1=1; result1=result1+1;zhengshu1=result1/16;dot1=result1&0x000f;dot1=(dot1*10)/16; shiwei1=(zhengshu1/10); gewei1=(zhengshu1%10); temperature1=zhengshu1+dot1*0.1; /通道二的十进制温度if(temperature1upper2) /通道二温度控制 COLD1=1; HEAT1=0; /超过预定温度的上限,启动小风扇
8、else if(temperature1max2|temperaturemin2) ALARM=0; /高于或低于设定温度的上下限,则报警 else ALARM=1; /屏幕的显示: if(qiehuan=0) /显示温度 if(choose=0) send(0x80); delay_50us(); if(symbol=1)send(0x0a); elsesend(0x0f); delay_50us(); send(0x81); delay_50us(); send(buffer1shiwei); delay_50us(); send(0x82); delay_50us(); send(buf
9、fer2gewei); delay_50us(); send(0x83); delay_50us(); send(buffer1dot); delay_50us(); else send(0x84); delay_50us(); if(symbol1=1)send(0x0a); elsesend(0x0f); delay_50us(); send(0x85); delay_50us(); send(buffer1shiwei1); delay_50us(); send(0x86); delay_50us(); send(buffer2gewei1); delay_50us(); send(0x
10、87); delay_50us(); send(buffer1dot1); delay_50us(); elseif(choose=0) /显示参数值send(0x80);delay_50us();send(buffer1max1/10);send(0x81);delay_50us();send(buffer1max1%10);send(0x82);delay_50us();send(buffer1min1/10);send(0x83);delay_50us();send(buffer1min1%10);send(0x84);delay_50us();send(buffer1upper1/10
11、);send(0x85);delay_50us();send(buffer1upper1%10);send(0x86);delay_50us();send(buffer1lower1/10);send(0x87);delay_50us();send(buffer1lower1%10);delay_50us();if(choose=1)send(0x80);delay_50us();send(buffer1max2/10);send(0x81);delay_50us();send(buffer1max2%10);send(0x82);delay_50us();send(buffer1min2/1
12、0);send(0x83);delay_50us();send(buffer1min2%10);send(0x84);delay_50us();send(buffer1upper2/10);send(0x85);delay_50us();send(buffer1upper2%10);send(0x86);delay_50us();send(buffer1lower2/10);send(0x87);delay_50us();send(buffer1lower2%10); CS=1; while(KEY); send(0x15); /第一个字节,读取键值命令字 delay_50us(); rece
13、ive();/第二个字节,读取键值,存放在变量rebuf中 delay_50us(); switch(rebuf)case 0x3F: /按键S1,选择一路choose=0;send(0x88);/第一个字节,闪烁控制命令字delay_50us();send(0xF0);/第二个字节,设置为闪烁CS=1; break;case 0x3E:/按键S2, 选择二路choose=1;send(0x88);/第一个字节,闪烁控制命令字delay_50us();send(0x0F);/第二个字节,设置为闪烁CS=1; break;case 0x36: /按键S4,开始修改qiehuan=1;key=7;
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 智能 温室 恒温 控制系统 语言 程序 22
限制150内