Smoke Detector Experiment2
Smoke Detector Experiment2
Appartus Required:
1. Arduino Uno
3. Jumper Wire
4. Buzzer
5. Potentiometer
Theory: In this circuit, the MQ2 gas sensor continuously monitors the smoke level in the
environment by sending analog values to the Arduino. The Arduino processes this data and
compares it to a predefined threshold. If the smoke level exceeds the threshold, the Arduino
activates a red LED to signal danger and triggers a buzzer for an audible alarm. If the smoke
level is below the threshold, the Arduino illuminates a green LED to indicate a safe
environment. This setup provides a simple yet effective smoke detection system, alerting users
to potential hazards with both visual and auditory signals.
Schematic Diagram:
Program used:
#include <Servo.h>
// Pin definitions
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(ledPin, OUTPUT);
void loop() {
// Ultrasonic sensor
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(smokeLevel);
} else {
Procedure:
1. Arduino Digital pin 0 is connected with the (+ve) pin of the buzzer.
2. Arduino Digital pin 1 is connected with the (+ve) pin of LED1 (green).
3. Arduino Digital pin 2 is connected with the (+ve) pin of LED2 (red).
4. Arduino Analog pin A0 is connected with A0 Pin of the MQ2 Gas sensor.
Circuit:
Precautions:
1. All the connections should be tight.
4. While making connections, take care of the pins of jumper wires as they are very thin and can
break easily.
Result:
Smoke detector has been successfully designed and implemented in the lab.