基于DS18B20溫度傳感器和MQ2煙霧傳感器的火災(zāi)報(bào)警器設(shè)計(jì)
一、概述
本文引用地址:http://m.butianyuan.cn/article/201807/383978.htm火災(zāi)自動(dòng)報(bào)警系統(tǒng)(Fire Alarm System,簡稱FAS系統(tǒng))是人們?yōu)榱嗽缙诎l(fā)現(xiàn)通報(bào)火災(zāi),并及時(shí)采取有效措施,控制和撲滅火災(zāi),而設(shè)置在建筑物中或其它場所的一種自動(dòng)消防設(shè)施,是人們同火災(zāi)作斗爭的有力工具。【1】
本設(shè)計(jì)中以溫度探頭和作為的傳感裝置,并以LED和蜂鳴器作為示警裝置。
二、功能
●高溫檢測。傳感器選用,當(dāng)環(huán)境溫度大于40℃,高溫報(bào)警指示燈亮,LCD1602第一行顯示溫度。
●環(huán)境煙霧濃度檢測。傳感器選用MQ2煙霧傳感器,AD0809作模數(shù)轉(zhuǎn)換傳煙霧濃度數(shù)據(jù)給單片機(jī)。當(dāng)環(huán)境煙霧濃度大于50時(shí),煙霧濃度指示燈亮,LCD1602第二行顯示煙霧濃度。
當(dāng)溫度和煙霧濃度同時(shí)過高時(shí),蜂鳴器發(fā)出報(bào)警聲音。
三、硬件設(shè)計(jì)
:DS18B20
煙霧傳感器:MQ2。MQ2輸出的模擬電壓信號(hào),使用ADC0809作模數(shù)轉(zhuǎn)換后輸入單片機(jī)。
四、程序設(shè)計(jì)
部分程序段:
○LCD1602顯示部分程序
#define LCD_DATA P0 //lcd1602的引腳
sbit LCD_RS = P2^0;
sbit LCD_RW = P2^1;
sbit LCD_EN = P2^2;
void LCD_Init(void)
{
Delay20ms();
LCD_WriteCmd(0x38); //8位機(jī)接口、雙行顯示、5×7字符點(diǎn)陣;
LCD_WriteCmd(0x0c); //顯示開啟、光標(biāo)不顯示也不閃爍;
LCD_WriteCmd(0x01); //清屏;
LCD_WriteCmd(0x06); //光標(biāo)右移一位、整屏不移動(dòng);
LCD_Goto(0,0);
}
void LCD_WriteDat(unsigned char lcd_dat)
{
unsigned char tmp;
tmp = LCD_ReadStatus(); //讀狀態(tài);
while((tmp 0x80)) //是否忙 ?
{
tmp = LCD_ReadStatus();
}
LCD_RS = 1;
LCD_RW = 0;
LCD_DATA = lcd_dat;
_nop_();
LCD_EN = 0;
_nop_();
_nop_();
LCD_EN = 1;
}
void LCD_WriteCmd(unsigned char lcd_cmd)
{
unsigned char tmp;
tmp = LCD_ReadStatus();
while((tmp 0x80))
{
tmp = LCD_ReadStatus();
}
LCD_RS = 0;
LCD_RW = 0;
LCD_DATA = lcd_cmd;
_nop_();
LCD_EN = 0;
_nop_();
_nop_();
LCD_EN = 1;
}
unsigned char LCD_ReadStatus(void)
{
unsigned char tmp;
#if 0
LCD_RS = 0;
LCD_RW = 1;
LCD_EN = 1;
tmp = LCD_DATA;
LCD_EN = 0;
#endif
LCD_DATA = 0xff;
LCD_RS = 0;
LCD_RW = 1;
LCD_EN = 0;
_nop_();
_nop_();
LCD_EN = 1;
tmp = LCD_DATA;
return tmp;
}
void LCD_Goto(unsigned char x,unsigned char y)
{
unsigned char tmp;
if(y) //若是第二行;
{
tmp = 0xc0 + x;
LCD_WriteCmd(tmp);
}
else
{
tmp = 0x80 + x;
LCD_WriteCmd(tmp);
}
}
void LCD_Display(unsigned char row,unsigned char *str)
{
if(row)
{
LCD_Goto(0,1);
}
else
{
LCD_Goto(0,0);
}
while(*str != '