#include<reg51.h>
#include<intrins.h> //包含头文件
#define uchar unsigned char
#define uint unsigned int //宏定义
////////////////////
sbit dj=P1^0;//电机控制端接口
sbit DQ=P1^6;//温度传感器接口
//////////按键接口/////////////////////////////////
sbit key1=P3^5;//设置温度
sbit key2=P3^6;//温度加
sbit key3=P3^7;//温度减
//////////////////////////////////////////////////////
sbit w1=P2^4;
sbit w2=P2^5;
sbit w3=P2^6;
sbit w4=P2^7; //数码管的四个位
/////共阴数码管段选//////////////////////////////////////////////
uchar table[22]=
{0x3F,0x06,0x5B,0x4F,0x66,
0x6D,0x7D,0x07,0x7F,0x6F,
0x77,0x7C,0x39,0x5E,0x79,0x71,
0x40,0x38,0x76,0x00,0xff,0x37};//'-',L,H,灭,全亮,n 16-21
uint wen_du; //温度变量
uint shang,xia; //对比温度暂存变量
uchar dang;//档位显示
uchar flag;
uchar d1,d2,d3;//显示数据暂存变量
void delay(uint ms) //延时函数,大约延时25us
{
uchar x;
for(ms;ms>0;ms--)
for(x=10;x>0;x--);
}
/***********ds18b20延迟子函数(晶振12MHz )*******/
void delay_18B20(uint i)
{
while(i--);
}
/**********ds18b20初始化函数**********************/
void Init_DS18B20()
{
uchar x=0;
DQ=1; //DQ复位
delay_18B20(8); //稍做延时
DQ=0; //单片机将DQ拉低
delay_18B20(80); //精确延时 大于 480us
DQ=1; //拉高总线
delay_18B20(14);
x=DQ; //稍做延时后 如果x=0则初始化成功 x=1则初始化失败
delay_18B20(20);
}
/***********ds18b20读一个字节**************/
uchar ReadOneChar()
{
uchar i=0;
uchar dat=0;
for (i=8;i>0;i--)
{
DQ=0; // 给脉冲信号
dat>>=1;
DQ=1; // 给脉冲信号
if(DQ)
dat|=0x80;
delay_18B20(4);
}
return(dat);
}
/*************ds18b20写一个字节****************/
void WriteOneChar(uchar dat)
{
uchar i=0;
for (i=8;i>0;i--)
{
DQ=0;
DQ=dat&0x01;
delay_18B20(5);
DQ=1;
dat>>=1;
}
}
/**************读取ds18b20当前温度************/
void ReadTemperature()
{
uchar a=0;
uchar b=0;
uchar t=0;
Init_DS18B20();
WriteOneChar(0xCC); // 跳过读序号列号的操作
WriteOneChar(0x44); // 启动温度转换
delay_18B20(100); // this message is wery important
Init_DS18B20();
WriteOneChar(0xCC); //跳过读序号列号的操作
WriteOneChar(0xBE); //读取温度寄存器等(共可读9个寄存器) 前两个就是温度
delay_18B20(100);
a=ReadOneChar(); //读取温度值低位
b=ReadOneChar(); //读取温度值高位
wen_du=((b*256+a)>>4); //当前采集温度值除16得实际温度值
}
void display()//显示温度
{
w1=0;P0=table[d1];delay(10); //第1位
P0=0x00;w1=1;delay(1);
w2=0;P0=table[16];delay(10);//第2位
P0=0x00;w2=1;delay(1);
w3=0;P0=table[d2]; delay(10);//第3位
P0=0x00;w3=1;delay(1);
w4=0;P0=table[d3];delay(10);//第4位
P0=0x00;w4=1;delay(1);
}
void zi_keyscan()//自动模式按键扫描函数
{
if(key1==0) //设置键按下
{
delay(30); //延时去抖
if(key1==0)flag=1; //再次判断按键,按下的话进入设置状态
while(key1==0);//松手检测 //按键释放
}
while(flag==1) //进入设置上限状态
{
d1=18;d2=shang/10;d3=shang%10; //显示字母H 和上限温度值
display(); //调用显示函数
if(key1==0) //判断设置键是否按下
{
delay(30); //延时去抖
if(key1==0)flag=2; //按键按下,进入设置下限模式
while(key1==0);//松手检测
}
if(key2==0) //加键按下
{
delay(30); //延时去抖
if(key2==0) //加键按下
{
shang+=5; //上限加5
if(shang>=100)shang=100; //上限最大加到100
}while(key2==0);//松手检测
}
if(key3==0) //减键按下
{
delay(30); //延时去抖
if(key3==0) //减键按下
{
shang-=1; //上限减1
if(shang<=10)shang=10; //上限最小减到10
}while(key3==0);//松手检测
}
}
while(flag==2) //设置下限
{
d1=17;d2=xia/10;d3=xia%10; //显示字母L 显示下限温度值
display(); //以下注释同上
if(key1==0)
{
delay(30);
if(key1==0)flag=0;
while(key1==0);//松手检测
}
if(key2==0)
{
delay(30);
if(key2==0)
{
xia+=5;
if(xia>=95)xia=95;
}while(key2==0);//松手检测
}
if(key3==0)
{
delay(30);
if(key3==0)
{
xia-=1;
if(xia<=0)xia=0;
}while(key3==0);//松手检测
}
}
}
void zi_dong()//自动温控模式
{
uchar i;
d1=dang;d2=wen_du/10;d3=wen_du%10; //显示档位,显示当前温度值
zi_keyscan();//按键扫描函数
display(); //调用显示函数
if(wen_du<xia){dj=0;dang=0;}//低于下限 档位为0 电机停止
if((wen_du>=xia)&&(wen_du<=shang))//温度大于下限,小于上限 1挡
{
dang=1; //档位置1
for(i=0;i<3;i++){dj=0;display();zi_keyscan();} //PWM通过延时得到
for(i=0;i<6;i++){dj=1;display();zi_keyscan();}
}
if(wen_du>shang){dj=1;dang=2;}//高温全速
}
void main() //主函数
{
uchar j;
dj=0; //电机开
shang=30;
xia=20; //初始上下限值
for(j=0;j<80;j++) //先读取温度值,防止开机显示85
ReadTemperature();
while(1) //进入while循环
{
ReadTemperature(); //读取温度值
for(j=0;j<100;j++)zi_dong();//自动温控模式
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
基于51单片机的智能温控风扇(代码+仿真)
共89个文件
zip:45个
log:8个
schlib:4个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
4星 · 超过85%的资源 2 下载量 3 浏览量
2024-05-12
10:18:05
上传
评论 3
收藏 5.46MB RAR 举报
温馨提示
基于51单片机的智能温控风扇基于51单片机的智能温控风扇系统,通常利用MCS-51系列单片机(如AT89C52)作为控制核心。这种智能温控风扇系统结合了51单片机的强大功能和智能温控技术,实现了对风扇转速的自动调节,以满足不同温度条件下的散热需求。 具体来说,基于51单片机的智能温控风扇系统具有以下功能: 温度监测与感应:系统通过温度传感器(如热敏电阻或数字温度传感器)实时监测环境温度,并将温度信息转换为电信号传输给单片机。 数据处理与分析:单片机接收到温度信息后,会进行数据处理和分析,判断当前温度是否在设定的温度范围内。 风扇控制:根据温度分析结果,单片机通过控制风扇的供电电压或电流来调节风扇的转速。当温度较高时,单片机会提高风扇的转速以增强散热效果;当温度较低时,单片机会降低风扇的转速以节约电能和减少噪音。 显示与交互:系统通常配备显示屏(如LCD显示屏),用于显示当前温度、风扇转速等信息。此外,系统还支持按键输入,用户可以通过按键来设置温度阈值、调整风扇转速等参数。 智能化管理:基于51单片机的智能温控风扇系统还具有智能化管理功能,如自动记忆、定时开关等。这些功能使得用户在使
资源推荐
资源详情
资源评论
收起资源包目录
基于51单片机的智能温控风扇(代码+仿真).rar (89个子文件)
基于51单片机的智能温控风扇(代码+仿真)
智能温控风扇.PcbDoc 972KB
SCH综合库.~(2).SchLib 2.27MB
tfengqing_SCH.~(9).SchLib 22B
Miscellaneous Devices.SchLib 1.06MB
温控风扇 程序.uvproj 14KB
final.PWI 1KB
温控风扇 程序.plg 182B
Miscellaneous Devices.PcbLib 560KB
智能温控风扇.pdsprj.XXY.HP.workspace 4KB
温控风扇程序.OBJ 12KB
智能温控风扇(1).zip 2.82MB
温控风扇 程序.uvgui.HP 83KB
Project Logs for 智能温控风扇
智能温控风扇 PCB ECO 2018-12-3 19-50-39.LOG 6KB
智能温控风扇 PCB ECO 2018-12-3 19-56-47.LOG 7KB
智能温控风扇 PCB ECO 2018-12-4 15-31-08.LOG 170B
智能温控风扇 PCB ECO 2018-12-5 19-24-11.LOG 7KB
智能温控风扇 PCB ECO 2018-12-4 15-32-25.LOG 170B
智能温控风扇 PCB ECO 2018-12-4 15-28-36.LOG 31B
智能温控风扇 PCB ECO 2018-12-5 22-51-17.LOG 31B
智能温控风扇 PCB ECO 2018-12-5 22-17-54.LOG 234B
温控风扇 程序 10KB
智能温控风扇.PcbDoc.htm 6KB
__Previews
智能温控风扇.SchDocPreview 56KB
温控风扇 程序.hex 3KB
Miscellaneous Connectors.PcbLib 875KB
History
智能温控风扇.~(5).SchDoc.Zip 16KB
智能温控风扇.~(8).SchDoc.Zip 16KB
智能温控风扇.~(4).PrjPcb.Zip 3KB
智能温控风扇.~(10).SchDoc.Zip 16KB
智能温控风扇库.~(5).PcbLib.Zip 7KB
智能温控风扇库.~(1).PcbLib.Zip 7KB
智能温控风扇.~(12).SchDoc.Zip 16KB
智能温控风扇.~(14).PcbDoc.Zip 25KB
智能温控风扇.~(9).SchDoc.Zip 16KB
智能温控风扇.~(11).PcbDoc.Zip 24KB
智能温控风扇.~(7).SchDoc.Zip 16KB
智能温控风扇.~(3).PcbDoc.Zip 23KB
智能温控风扇.~(18).PcbDoc.Zip 79KB
智能温控风扇.~(3).SchDoc.Zip 16KB
智能温控风扇.~(15).SchDoc.Zip 19KB
智能温控风扇库.~(4).PcbLib.Zip 7KB
智能温控风扇.~(4).PcbDoc.Zip 24KB
智能温控风扇.~(8).PcbDoc.Zip 23KB
智能温控风扇.~(4).SchDoc.Zip 16KB
智能温控风扇.~(10).PcbDoc.Zip 23KB
智能温控风扇.~(7).PcbDoc.Zip 13KB
智能温控风扇.~(1).SchDoc.Zip 1KB
智能温控风扇.~(12).PcbDoc.Zip 24KB
智能温控风扇.~(17).PcbDoc.Zip 79KB
智能温控风扇.~(5).PcbDoc.Zip 24KB
智能温控风扇.~(6).PcbDoc.Zip 24KB
智能温控风扇.~(16).PcbDoc.Zip 37KB
智能温控风扇.~(19).PcbDoc.Zip 614KB
智能温控风扇.~(13).PcbDoc.Zip 24KB
智能温控风扇库.~(3).PcbLib.Zip 7KB
智能温控风扇.~(2).PrjPcb.Zip 3KB
智能温控风扇.~(14).SchDoc.Zip 19KB
智能温控风扇.~(13).SchDoc.Zip 16KB
智能温控风扇.~(1).PcbDoc.Zip 12KB
智能温控风扇.~(11).SchDoc.Zip 16KB
智能温控风扇.~(3).PrjPcb.Zip 3KB
智能温控风扇库.~(2).PcbLib.Zip 7KB
智能温控风扇库.~(7).PcbLib.Zip 7KB
智能温控风扇.~(15).PcbDoc.Zip 25KB
智能温控风扇.~(2).PcbDoc.Zip 13KB
智能温控风扇.~(9).PcbDoc.Zip 24KB
智能温控风扇库.~(6).PcbLib.Zip 7KB
智能温控风扇.~(1).PrjPcb.Zip 3KB
智能温控风扇.~(6).SchDoc.Zip 16KB
温控风扇 程序_uvopt.bak 54KB
温控风扇 程序.uvopt 5KB
智能温控风扇.PWI 1KB
Last Loaded 智能温控风扇.DBK 185KB
智能温控风扇.SchDoc 161KB
智能温控风扇库.PcbLib 47KB
智能温控风扇.PrjPcb 24KB
Last Loaded final.DBK 189KB
Project Backups
智能温控风扇 [20240503, 12-21-58].pdsprj 30KB
tfengqing_PCB.~(2).PcbLib 590KB
温控风扇程序.LST 9KB
温控风扇 程序.lnp 42B
温控风扇 程序_uvproj.bak 0B
温控风扇 程序.uvgui.YY 88KB
温控风扇 程序.build_log.htm 1008B
Miscellaneous Connectors.SchLib 832KB
温控风扇程序.c 5KB
智能温控风扇.pdsprj 30KB
温控风扇 程序.M51 14KB
智能温控风扇.PrjPcbStructure 92B
共 89 条
- 1
资源评论
- cool2922024-06-02为什么打不开
- 临水照花4032024-05-22总算找到了想要的资源,搞定遇到的大问题,赞赞赞!
科创工作室li
- 粉丝: 3751
- 资源: 67
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功