Putra Maulana Arifanggi
Published

Smoke Detection System For Non-Smoking Environments

MQ-2 smoke sensors are programmed to provide input to the microcontroller so as to detect the presence or extent of air pollution to smoke

BeginnerWork in progress1,364
Smoke Detection System For Non-Smoking Environments

Things used in this project

Hardware components

Grove - Gas Sensor(MQ2)
Seeed Studio Grove - Gas Sensor(MQ2)
×1
Arduino Leonardo
Arduino Leonardo
×1
Relay Shield for Particle Photon I²C 8-Channel SPDT 10-Amp
ControlEverything.com Relay Shield for Particle Photon I²C 8-Channel SPDT 10-Amp
×1
I2C 16x2 Arduino LCD Display Module
DFRobot I2C 16x2 Arduino LCD Display Module
×1
Buzzer
Buzzer
×1
Linear Regulator (7805)
Linear Regulator (7805)
×1
Capacitor 1000 µF
Capacitor 1000 µF
×1
Resistor 220 ohm
Resistor 220 ohm
×1
LED (generic)
LED (generic)
×1
1N4007 – High Voltage, High Current Rated Diode
1N4007 – High Voltage, High Current Rated Diode
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

System suite scheme

Code

Project_Final

Arduino
#include <servo.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, A5, A4, A3, A2, A1);
Servo Servo;
const int analog?in= A0;
const int indbukanasap= 10;
const int indadaasap= 13;
int buzzer= 9;
int SensorValue= 0;
int pos1= 50;
int pos2= 0;
int incomingByte= 0;

void setup(){
	Serial.begin(9600);
	lcd.begin(16, 2);
	pinMode (indbukanasap, OUTPUT);
	pinMode (indadaasap, HIGH);
digitalWrite (indadaasap, HIGH);
	pinMode (buzzer, OUTPUT);
	servo.attach (6);
	servo.write (pos1);
}

void loop()
{
	if (Serial.available() > 0) {
	// Membaca data
	incomingByte = Serial.read();
	}

	switch (incomingByte)
{
	case '0' :
	servo.write(30);
	break;

	case '1' :
	servo.write(15);
	break;

	case '2' :
	servo.write(70);
	break;

	case '3' :
	servo.write(85);
	break;
	case '4' :
	servo.write(pos1);
	break;
	delay(15);

}

SensorValue=analogRead(0);
	Serial.printIn(SensorValue, DEC);
	delay(100);
	if (SensorValue >= 520){
		for (pos2 = 0; pos2 < 85; pos2 += 1)
{
	
	lcd.display();
	lcd.setCursor(0,0);
	lcd.ptint("ASAP TERDETEKSI");
	lcd.setCursor (0,1);
	lcd.print("ADA YANG MEROKOK");
	delay(100);

	lcd.clear();
	servo.write(pos2);
	digitalWrite(indbukanasap, LOW);
	digitalWrite(indadaasap, HIGH);
	delay(100);
	digitalWrite(indadaasap, LOW);
	tone(buzzer, 1950, 956);
	delay(100);
}
for(pos2 = 85; pos2>=1; pos2-=1)
{

lcd.display();
	lcd.setCursor(0,0);
	lcd.print("ASAP TERDETEKSI");
	lcd.setCursor (0,1);
	lcd.print("ADA YANG MEROKOK");
	delay(200);

	lcd.clear();
	servo.write(pos2);
	digitalWrite(indbukanasap, LOW);
	digitallWrite(indadaasap, HIGH);
	delay(100);
	digitalWrite(indadaasap, LOW);
	tone(buzzer, 1950, 956);
	delay(100);
}
}
else {
lcd.display();
	lcd.setCursor(0,0);
	lcd.print("KONDISI RUANG");
	lcd.setCursor (0,1);
	lcd.print("BEBAS ASAP");
	//delay(500);
	delay(500);
lcd.clear();
	servo.write(pos1);
	digitalWrite(indbukanasap, HIGH);
digitalWrite(indadaasap, LOW);
}

}

Credits

Putra Maulana Arifanggi

Putra Maulana Arifanggi

1 project • 0 followers

Comments