一.系统概述
本设计的火灾检测报警系统通过温度传感器和烟雾传感器来进行监测。温度传感器用于检测环境温度,烟雾传感器则用于监测烟雾浓度。系统将实时数据显示在屏幕上,并在检测到烟雾浓度或温度超过预设阈值时触发报警并启动灭火装置。
二.仿真概述
- 仿真启动后,显示屏将展示当前的温度和烟雾浓度数据,并实时显示设定的阈值。
- 调整烟雾传感器的滑动变阻器,当烟雾浓度超出设定阈值时,系统会自动触发报警并启动灭火装置。
- 调节DS18B20传感器的红色按钮,当温度超过设定阈值时,系统同样会发出报警并启动灭火功能。
- 通过按键可以设定温度和烟雾浓度的阈值。按下设置按钮进行阈值调整,设置完成后需要按下确认按钮保存设置。
三.程序设计
#include <stm32f10x.h>
#include <Lcd1602.h>
#include <Led.h>
#include <Ds18b20.h>
#include <Beep.h>
#include <Relay.h>
#include <key.h>
#include "PCF8591.h"
int main(void)
{
u8 t,s,k,m=0,Tmax = 50,Smax=50;
Key_Init();
Lcd1602_Init();
Led1_Init();//PC0
Beep_Init();//PA13
Ds18b20_Init();//PA12
PCF8591_Init();
Lcd1602_Write_String(0x80,2,(u8*)"T:");
Lcd1602_Write_String(0x86,2,(u8*)"!:");
Lcd1602_Write_String(0xc0,2,(u8*)"S:");
Lcd1602_Write_String(0xc6,2,(u8*)"!:");
Lcd1602_Write_String(0xc4,2,(u8*)"%");
while(1)
{
k =Key_detect();
Lcd1602_Write_Num8(0x8c,m);
t =Ds18b20_Temp() ;
s =PCF8591_ADC_Input(0x90,1);
Lcd1602_Write_Num8(0x82,t);
Lcd1602_Write_Num8(0x88,Tmax);
Lcd1602_Write_Num8(0xc2,s);
Lcd1602_Write_Num8(0xc8,Smax);
if(Key2==0)
{
m++;
if(m==3) m=0;
}
if(Key3==0)
{
m=0;
}
//
if(m==1)
{
Lcd1602_Write_String(0xcA,1,(u8*)" ");
Lcd1602_Write_String(0x8A,1,(u8*)"<");
if(Key0==0) Tmax++;
else if(Key1==0) Tmax--;
}
else if(m==2)
{
Lcd1602_Write_String(0x8A,1,(u8*)" ");
Lcd1602_Write_String(0xcA,1,(u8*)"<");
if(Key0==0) Smax++;
else if(Key1==0) Smax--;
}
else if(m==0)
{
Lcd1602_Write_String(0x8A,1,(u8*)" ");
Lcd1602_Write_String(0xcA,1,(u8*)" ");
if(t>Tmax||s>Smax)
{
Beep_1;Led1_1;
}
else if(t<Tmax&&s<Smax)
{
Beep_0;Led1_0;
}
}
}
}
24-32f-28