基于MSP430低功耗烟雾采集智能报警系统设计(毕设课设)
MSP430烟雾报警器
设计基于MSP430的烟雾报警器
要求是设计尽量采取低功耗模式,延长电池使用寿命,当有烟雾产生时,报警器产生声音报警信号
#include <msp430x14x.h>
#include "delay.h"
#include "1602.h"
#include "typedef.h"
#include "ds18b20.h"
#define LED1_ON (P4OUT &= ~BIT2)
#define LED1_OFF (P4OUT |= BIT2)
#define LED2_ON (P4OUT &= ~BIT3)
#define LED2_OFF (P4OUT |= BIT3)
#define Buzzer_ON (P2OUT &= ~BIT7)
#define Buzzer_OFF (P2OUT |= BIT7)
#define Num_of_Results 32
static uint A0Results[Num_of_Results];
static uint A1Results[Num_of_Results];
/*------------------按键定义-------------------------*/
#define K0_Val (P6IN & BIT3) //注意一定要加(), P2IN & BIT1 不管用
#define K1_Val (P6IN & BIT4)
#define K2_Val (P6IN & BIT5)
#define K3_Val (P6IN & BIT6)
/*-------------------------------------*/
void Clock_Init(); //把时钟切换到成8M时钟
void ADC12_Init(void);
void System_Init(void);
void Warning_Control(void);
unsigned int MQ2=0;
unsigned int AlarmVal[2]={800,1500};
uchar AlarmFlag[2]={0};
unsigned char Page=0; //页面显示012分别显示
void DisplayInit(void);
void KeyInit(void);
void LED_Init(void);
void PageDisplay(void);
void SetVal(void)
{
if(K0_Val==0) //减
{
if(K1_Val==0)
{
delay_ms(50);
if(K1_Val==0)
{
if(AlarmVal[Page]>50)
AlarmVal[Page]-=50;
else
AlarmVal[Page]=50;
delay_ms(150);
}
}
if(K2_Val==0)
{
delay_ms(50);
if(K2_Val==0)
{
if(AlarmVal[Page]>50)
AlarmVal[Page]-=10;
else
AlarmVal[Page]=50;
delay_ms(150);
}
}
}
【资源下载】下载地址如下(881):https://docs.qq.com/doc/DTlRSd01BZXNpRUxl