prasad1999
Published

Gas Leak Detector

This device can detect the concentration of harmful gases present in the air and act as a gauge/alarm system.

BeginnerShowcase (no instructions)466
Gas Leak Detector

Things used in this project

Story

Read more

Schematics

Diagram

Code

Smoke/ Gas leak detector

Arduino
#include <LiquidCrystal.h>
LiquidCrystal lcd(7,6,5,4,3,2);

int redLed = 10;
int greenLed = 12;
int buzzer = 8;
int smokeA0 = A0;
// Your threshold value
int sensorThres = 625;

void setup() {
  pinMode(redLed, OUTPUT);
  pinMode(greenLed,OUTPUT);
  pinMode(buzzer,OUTPUT);
  pinMode(smokeA0, INPUT);
  Serial.begin(9600);
  lcd.begin(16,2);
}

void loop() {
  int analogSensor = analogRead(smokeA0);

  Serial.print("Pin A0: ");
  Serial.println(analogSensor);
  lcd.print("Smoke level:");
  lcd.print(analogSensor-200);

  if (analogSensor-200 > sensorThres)
  {
    digitalWrite(redLed,HIGH);
    lcd.setCursor(0,2);
    lcd.print("!!!ALERT!!!");
    digitalWrite(greenLed,LOW);
    tone(buzzer,1000,200);
  }
  else
  {
    digitalWrite(redLed,LOW);
    digitalWrite(greenLed,HIGH);
    lcd.setCursor(0, 2);
    lcd.print(".....NORMAL.....");
    noTone(buzzer);
  }
  delay(100);
  lcd.clear();
}

Credits

prasad1999

prasad1999

1 project • 2 followers

Comments