【资源下载】下载地址如下:
https://docs.qq.com/doc/DTlRSd01BZXNpRUxl
三个ds18b20分别采集进水口热水 冷水 和温水的水温,然后分别显示出来,按下开始按键,系统初始化,自动设置出水温度为38度,可以通过按键加减进行微调,在淋浴过程中,通过人体红外传感检测是否有人,离开花洒下面,自动停水且停止温度调节,回去过重新打开。温度控制通过热水阀和冷水阀的开关进行调节水温。
#include "lcd1602.h" #include "ds18b20.h" #include "DS1302.h" #include "24C16B.h" sbit WN = P3 ^ 7; sbit PE = P3 ^ 4; sbit JIN = P3 ^ 5; sbit X0 = P3 ^ 2; sbit X1 = P3 ^ 3; sbit JIA = P1 ^ 3; sbit JIAN = P1 ^ 6; uchar n = 1, count = 0, smb = 0; uchar war = 40; extern char zhen_temp[5], *wendu; extern bit flag; uchar code ds18b20_num1[8] = { 0xfd, 0x00, 0x00, 0x00, 0xb8, 0xc5, 0x45, 0x28 }; uchar code ds18b20_num2[8] = { 0x8e, 0x00, 0x00, 0x00, 0xb8, 0xc5, 0x30, 0x28 }; uchar code ds18b20_num3[8] = { 0xb9, 0x00, 0x00, 0x00, 0xb8, 0xc5, 0x31, 0x28 }; uchar code ds18b20_num4[8] = { 0xe0, 0x00, 0x00, 0x00, 0xb8, 0xc5, 0x32, 0x28 }; void delay( unsigned int time ) { unsigned int i, j; for ( i = 0; i < time; i++ ) for ( j = 0; j < 200; j++ ) ;