Arduino UNO R3開發板+MQ-2煙霧濃度傳感器+火焰傳感器+舵機+無源蜂鳴器+風扇+步進電機+WIFI模塊+RGB三色LED燈+SIM900A所構成的室內安全報警模塊

該系統模塊主要由Arduino UNO R3開發板+MQ-2煙霧濃度傳感器+火焰傳感器+舵機+無源蜂鳴器+風扇+步進電機+WIFI模塊+RGB三色LED燈+SIM900A所組成,MQ-2煙霧濃度傳感器達到不同的閾值的時候,LED燈會通過不同的顏色來進行警示。煙霧濃度增大,LED燈依次顯示綠、藍、紅,且步進電機會驅動風扇進行不同擋位轉速旋轉,蜂鳴器會進行警報提示。煙霧濃度超過最大的閾值,或者檢測到有火焰產生,紅燈亮起,蜂鳴器鳴響,步進電機以最大的轉速驅動風扇旋轉,SIM900A會給指定用戶撥打電話。
因為該模塊有WiFi模塊,也可以通過連接WiFi通過APP進行控制步進電機的轉速驅動,也可以實現手動的控制風扇轉速。

一、設備準備

Arduino UNO R3Arduino UNO R3開發板+MQ-2煙霧濃度傳感器+舵機+無源蜂鳴器+風扇+步進電機+WIFI模塊+RGB三色LED燈+SIM900A所構成。MQ-2煙霧濃度傳感器實時檢測室內煙霧濃度數值,若超過閾值,風扇進行轉動
在這里插入圖片描述
WIFI模塊
在這里插入圖片描述
MQ-2煙霧濃度傳感器
在這里插入圖片描述
火焰傳感器模塊
在這里插入圖片描述

舵機
在這里插入圖片描述
無源蜂鳴器
在這里插入圖片描述
風扇
在這里插入圖片描述
RGB三色LED燈
在這里插入圖片描述

步進電機
在這里插入圖片描述
SIM900A
在這里插入圖片描述

二、設備連接

煙霧濃度傳感器

煙霧濃度傳感器Arduino UNO R3
VCC5V
GNDGND
DOP7
AOA0

火焰傳感器

火焰傳感器Arduino UNO R3
DOP2
GNDGND
VCC5V

無源蜂鳴器

無源蜂鳴器Arduino UNO R3
GNDGND
I/OP8
VCC5V

三色LED燈

三色LED燈Arduino UNO R3
RP11
GP12
BP13
GNDGND

步進電機

步進電機Arduino UNO R3
IN3P9
IN4P4
+5V
-GND

風扇

風扇步進電機
紅線B燈處
黑線C燈處

WIFI模塊(局域模式)

WIFI模塊Arduino UNO R3
RXTX
TXRX
GNDGND
5V5V

SIM900A模塊

SIM900AArduino UNO R3
5VRTX
5VTRX
GNDGND
VCC55V
GNDGND

舵機模塊

舵機Arduino UNO R3
黃線P6
灰線GND
紅線5V

三、配置網絡

將代碼下載到Arduino UNO R3開發板上
WIFI模塊需要調節到局域模式,此時打開手機wifi熱點,即可檢測到WiFi模塊所組成的網絡,在這里插入圖片描述,進行連接。
APP下載路徑,打開下載安裝好的手機APP
在這里插入圖片描述
之后,點擊右上角的連接在這里插入圖片描述
連接成功之后,即可點擊 開鎖(49)、加速、減速、蜂鳴器開(50)、蜂鳴器關(51)、一檔、二檔、三檔 可以對舵機、蜂鳴器以及風扇進行控制。

四、完整代碼

/******************************************************* connection:* MQ-2 gas sensor            Uno R3* D0                            7* A0                            A0* GND                           GND* VCC                            5V* * * Dual-color LED    Arduin Uno R3* R                  11* G                  12* B                  13* GND                GND* * * buzzerPin                      8* GND                           GND* VCC                            5V* * * motorIn1 = 9;* motorIn2 = 10;* *******************************************************/
#include <Servo.h>  //Arduino IDE自帶的舵機庫文件
const int Servo_Pin = 6;      //模擬開門
Servo myservo;      //定義舵機對象myservoconst int digitalInPin = 2; //D0 attach to digital 2const int analogPin=A0; //the DO on the Module attach to Pin7 on the SunFounder 
const int digitalPin=7;  //the D0 attach to pin7
int Astate=0;
boolean  Dstate=0;int redPin = 11;    // select the pin for the red LED
int greenPin = 12; 
int bluePin = 13; int buzzerPin = 8;//the pin of the active buzzer attach to pin8
int comdata;
const int motorIn1 = 9;
const int motorIn2 = 4;
#define rank1 150
#define rank2 200
#define rank3 250void set_tele(void)
{Serial.begin(115200);                  //波特率為115200delay(1000);Serial.println("AT\r\n");                  //判斷模塊是否正常delay(1000);
}
void tele(void)
{Serial.println("AT+CPIN?\r\n");         delay(1000);Serial.println("AT+CSQ\r\n");              delay(3000);Serial.print("AT+CREG?\r\n");          delay(3000);Serial.println("AT+CGATT?\r\n");  delay(1000);Serial.println("ATD15336551683;\r\n");      delay(30000);
}void setup() 
{pinMode(digitalInPin,INPUT);//set the pins state pinMode (digitalPin,INPUT);pinMode(redPin, OUTPUT); //set redPin as OUTPUTpinMode(greenPin, OUTPUT);pinMode(bluePin, OUTPUT);pinMode(buzzerPin,OUTPUT);//set the buzzer as as OUTPUTdigitalWrite(buzzerPin,LOW);//initialize the buzzerPin as LOW levelpinMode(motorIn1,OUTPUT);pinMode(motorIn2,OUTPUT);pinMode(Servo_Pin, OUTPUT);  //初始化舵機為輸出模式myservo.attach(Servo_Pin);    //設置舵機控制引腳為6myservo.write(0);    //初始化舵機位置0set_tele();Serial.begin(9600);
} 
void loop()
{  boolean stat = digitalRead(digitalInPin);Serial.print("D0: "); Serial.println(stat); // print to serial monitor Serial.println(" ");Astate=analogRead(analogPin);//read the value of A0Serial.println(Astate); //peint if( stat == LOW){analogWrite(motorIn1,0);analogWrite(motorIn2,rank3);analogWrite(redPin, 255); //redanalogWrite(greenPin, 0);analogWrite(bluePin, 0);//digitalWrite(buzzerPin,LOW);myservo.write(90); //舵機旋轉至90度delay(5000);      // 延時3000msmyservo.write(0);//舵機旋轉至0度delay(1000);      // 延時3000msfor(int i = 200;i <= 500;i++)   //frequence loop from 200 to 800{tone(8,i);   //in pin7 generate a tone,it frequence is idelay(2);    //wait for 5 milliseconds   }delay(1000);   //wait for 4 seconds on highest frequencefor(int i = 500;i >= 200;i--)  //frequence loop from 800 downto 200{tone(8,i);  //in pin7 generate a tone,it frequence is idelay(2);  //delay 10ms}tele();}if((Astate>120 && Astate<150)){analogWrite(motorIn1,0);analogWrite(motorIn2,rank1);analogWrite(redPin, 0); //redanalogWrite(greenPin, 255);analogWrite(bluePin, 0);//digitalWrite(buzzerPin,LOW);myservo.write(90); //舵機旋轉至90度delay(5000);      // 延時3000msmyservo.write(0);//舵機旋轉至0度delay(1000);      // 延時3000msfor(int i = 200;i <= 500;i++)   //frequence loop from 200 to 800{tone(8,i);   //in pin7 generate a tone,it frequence is idelay(10);    //wait for 5 milliseconds   }delay(4000);   //wait for 4 seconds on highest frequencefor(int i = 500;i >= 200;i--)  //frequence loop from 800 downto 200{tone(8,i);  //in pin7 generate a tone,it frequence is idelay(10);  //delay 10ms}}else if((Astate>=150 && Astate<200)){analogWrite(motorIn1,0);analogWrite(motorIn2,rank2);analogWrite(redPin, 0); //redanalogWrite(greenPin, 0);analogWrite(bluePin, 255);//digitalWrite(buzzerPin,LOW);myservo.write(90); //舵機旋轉至90度delay(5000);      // 延時3000msmyservo.write(0);//舵機旋轉至0度delay(1000);      // 延時3000msfor(int i = 200;i <= 500;i++)   //frequence loop from 200 to 800{tone(8,i);   //in pin7 generate a tone,it frequence is idelay(5);    //wait for 5 milliseconds   }delay(2000);   //wait for 4 seconds on highest frequencefor(int i = 500;i >= 200;i--)  //frequence loop from 800 downto 200{tone(8,i);  //in pin7 generate a tone,it frequence is idelay(5);  //delay 10ms}}else if((Astate>=200)){analogWrite(motorIn1,0);analogWrite(motorIn2,rank3);analogWrite(redPin, 255); //redanalogWrite(greenPin, 0);analogWrite(bluePin, 0);//digitalWrite(buzzerPin,LOW);myservo.write(90); //舵機旋轉至90度delay(5000);      // 延時3000msmyservo.write(0);//舵機旋轉至0度delay(1000);      // 延時3000msfor(int i = 200;i <= 500;i++)   //frequence loop from 200 to 800{tone(8,i);   //in pin7 generate a tone,it frequence is idelay(2);    //wait for 5 milliseconds   }delay(1000);   //wait for 4 seconds on highest frequencefor(int i = 500;i >= 200;i--)  //frequence loop from 800 downto 200{tone(8,i);  //in pin7 generate a tone,it frequence is idelay(2);  //delay 10ms}tele();
/*      Serial.print("AT+CMGD=1");Serial.print("\r\n");Serial.print("AT");Serial.print("\r\n");Serial.print("AT+CPIN?");Serial.print("\r\n");Serial.print("AT+CSQ");Serial.print("\r\n");Serial.print("AT+CREG?");Serial.print("\r\n");Serial.print("AT+CGATT?");Serial.print("\r\n");Serial.print("ATD15336551683;");Serial.print("\r\n");
*/    }else{analogWrite(redPin, 0); //redanalogWrite(greenPin, 0);analogWrite(bluePin, 0);//digitalWrite(buzzerPin,HIGH);pinMode(buzzerPin,INPUT);pinMode(motorIn1,0);pinMode(motorIn2,0);}delay(200);//delay 200mswhile (Serial.available()){comdata= Serial.read();if(comdata==49){Serial.print("open the door\n");myservo.write(90); //舵機旋轉至90度delay(1000);      // 延時3000msmyservo.write(0);//舵機旋轉至0度delay(1000);      // 延時3000ms}if(comdata==50){Serial.print("open fmq\n");for(int i = 200;i <= 500;i++)   //frequence loop from 200 to 800{tone(8,i);   //in pin7 generate a tone,it frequence is idelay(5);    //wait for 5 milliseconds   }delay(4000);   //wait for 4 seconds on highest frequencefor(int i = 500;i >= 200;i--)  //frequence loop from 800 downto 200{tone(8,i);  //in pin7 generate a tone,it frequence is idelay(10);  //delay 10ms}delay(100);}if(comdata==51){Serial.print("close fmq\n");pinMode(buzzerPin,INPUT);delay(100);}if(comdata==52){Serial.print("111\n");analogWrite(motorIn1,0);analogWrite(motorIn2,rank1);delay(100);}if(comdata==74){Serial.print("222\n");analogWrite(motorIn1,0);analogWrite(motorIn2,rank2);delay(100);}if(comdata==54){Serial.print("333\n");analogWrite(motorIn1,0);analogWrite(motorIn2,rank3);delay(100);}}
}

五、演示視頻

B站演示視頻
CSDN演示視頻

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/377765.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/377765.shtml
英文地址,請注明出處:http://en.pswp.cn/news/377765.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

highcharts中series帶參數的賦值問題

需要得到的代碼如下&#xff1a; series: [{name: 棒號1,data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]}, {name: 棒號2,data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5]}, {name: 棒號3,data: [-0.9, 0.6, 3.5, …

可編程ic卡 通用嗎_8255可編程IC

可編程ic卡 通用嗎Introduction 介紹 An 8255 programmable integrated circuit (IC) is an IC used for interfacing the microprocessor with the peripheral devices. It is a 40 pin IC which was introduced by INTEL to use with its 8085 and 8086 microprocessors. 82…

POJ 1944 Fiber Communications (枚舉 + 并查集 OR 線段樹)

題意 在一個有N&#xff08;1 ≤ N ≤ 1,000&#xff09;個點環形圖上有P&#xff08;1 ≤ P ≤ 10,000&#xff09;對點需要連接。連接只能連接環上相鄰的點。問至少需要連接幾條邊。 思路 突破點在于最后的結果一定不是一個環&#xff01;所以我們枚舉斷邊&#xff0c;則對于…

九、邏輯回歸多分類和softmax多分類

一、邏輯回歸多分類 假設激活函數使用的是sigmoid函數 邏輯回歸多分類其實是多個二分類而已&#xff0c;若求三分類問題需要對訓練的數據樣本進行適當的修改調整即可&#xff0c;如何修改樣本數據可以參考邏輯回歸二分類和多分類本質區別&#xff0c;內容都一樣&#xff0c…

【C++grammar】繼承與構造test1代碼附錄

目錄1、main.cpp2、circle.cpp3、circle.h4、rectangle.cpp5、rectangle.h6、Shape.h1、main.cpp #include <iostream> #include <string> #include "Shape.h" #include "circle.h" #include "rectangle.h"//創建Shape/Circle/Rect…

hdu 4747 mex 線段樹+思維

http://acm.hdu.edu.cn/showproblem.php?pid4747 題意&#xff1a; 我們定義mex(l,r)表示一個序列a[l]....a[r]中沒有出現過得最小的非負整數&#xff0c; 然后我們給出一個長度為n的序列&#xff0c;求他所有的連續的子序列的mex(l,r)的和。 思路&#xff1a; 首先因為n的最大…

十、評估指標

我看過很多課程&#xff0c;不過內容都大差不差&#xff0c;也可以參考這篇模型評估方法 一、K折交叉驗證 一般情況&#xff0c;我們得到一份數據集&#xff0c;會分為兩類&#xff0c;一類是trainset訓練集&#xff0c;另一類十testset測試集。通俗一點也就是訓練集相當于平…

leetcode 47. 全排列 II 思考分析

題目 給定一個可包含重復數字的序列 nums &#xff0c;按任意順序 返回所有不重復的全排列。 思考分析以及代碼 這一題和前面的做過的兩個題目有所關聯&#xff1a; leetcode 46. 全排列 思考分析 再加上leetcode 491. 遞增子序列 思考分析類似的去重操作。 先畫出解空間樹…

python添加數組元素_在Python中向數組添加元素

python添加數組元素An array can be declared by using "array" module in Python. 可以通過在Python中使用“數組”模塊來聲明數組 。 Syntax to import "array" module: 導入“數組”模塊的語法&#xff1a; import array as array_alias_nameHere, im…

hdu 4472 Count(遞推即dp)

題目鏈接&#xff1a;http://acm.hdu.edu.cn/showproblem.php?pid4472 代碼&#xff1a; #include <cstdio> #include <cstring> #include <iostream> #include <cmath> #include <algorithm> #include <queue> #include <vector> …

如何在Java中同步ArrayList?

同步ArrayList (Synchronizing ArrayList) In java, there are two ways to synchronize ArrayList, 在Java中&#xff0c;有兩種同步ArrayList的方法&#xff0c; With the help of synchronizedList() method 借助syncedList()方法 With the help of CopyOnWriteArrayList&l…

十一、決策樹和隨機森林

這門課和另一門課內容都差不多&#xff0c;可以參考七、決策樹算法和集成算法該篇博文。 一、決策樹相關概念 邏輯回歸本質 邏輯回歸&#xff1a;線性有監督分類模型。常用求解二分類問題&#xff0c;要么是A類別要么是B類別&#xff0c;一般會以0.5作為劃分閾值&#xff0c…

【C++grammar】繼承與構造

目錄1.繼承1、Inheritance (繼承)2、避免一個類被繼承&#xff08; C11 &#xff09;3、繼承實例4、完整代碼5、繼承的優缺點是什么?2.繼承中的構造函數1、 派生類繼承的成員2、調用基類構造函數3.繼承中的默認構造函數1、基類的無參構造函數2、由編譯器自動生成的基類構造函數…

C語言預處理

所謂預處理是指在進行編譯的第一遍掃描(詞法掃描和語法分析)之前所作的工作。預處理是&#xff23;語言的一個重要功能&#xff0c; 它由預處理程序負責完成。當對一個源文件進行編譯時&#xff0c; 系統將自動引用預處理程序對源程序中的預處理部分作處理&#xff0c; 處理完畢…

(轉)將cocos2dx項目從VS移植到Eclipse

本文轉自:http://www.cnblogs.com/Z-XML/p/3349518.html 引言&#xff1a;我們使用cocos2d-x引擎制作了一款飛行射擊游戲&#xff0c;其中創新性地融入了手勢識別功能。但是我們在移植過程中遇到了很多的問題&#xff0c;同時也發現網上的資料少而不全。所以在項目行將結束的時…

十二、聚類算法——相似度測量

兩套學習資料都類似&#xff0c;可參考聚類算法實戰 一、聚類 聚類&#xff1a;物以類聚&#xff0c;人以群分&#xff0c;是無監督學習中的一種。 沒有y&#xff0c;只有x&#xff0c;把不同的x根據相似度自動的聚成好多堆兒 本質上&#xff0c;N個樣本&#xff0c;映射到K個…

操作系統磁盤調度_磁盤調度| 操作系統

操作系統磁盤調度磁盤調度 (Disk Scheduling) One of the major duties of the operating is that, to use the hardware orderly and accurately. For disk drives, it has a duty of having a fast access time and disk bandwidth. Generally, bandwidth is the total numbe…

leetcode 344. 反轉字符串 541. 反轉字符串 II 雙指針解

目錄leetcode 344.反轉字符串1、題目2、思考leetcode 541. 反轉字符串 II1、題目2、思考leetcode 344.反轉字符串 1、題目 2、思考 典型的雙指針解法&#xff1a; 一個從前往后&#xff0c;一個從后往前&#xff0c;指針對應的交換即可。 class Solution { public:void reve…

關于銀聯在線支付和短彩信接口的開發——總結

9月份開始做用二維碼做閉環的一個在線訂購景區門票的項目&#xff0c;其中這樣做是很好的&#xff0c;用二維碼連接了線上與線下的交易和兌券。銀聯在線支付接口&#xff08;asp.net cs&#xff09;做的很好&#xff0c;方便調用開發。就是處理回值的時候得找個更好的方法才能顯…

十三、聚類算法

六、聚類算法實戰 一、聚類 聚類是一種無監督的機器學習任務&#xff0c;可以自動將數據劃分為類cluster&#xff0c;因此聚類分組不需要提前被告知所劃分的組應該是什么樣子的。因為我們甚至可能都不知道我們在尋找什么&#xff0c;所以聚類是用于知識發現而不是預測。 聚類…