Khaled Md Saifullah
Published © MIT

Automatic Gas Reduction System

This is a project on automatic exhaust fan that can be triggered when gas level of a room will be increased.

IntermediateFull instructions provided2 hours1,469
Automatic Gas Reduction System

Things used in this project

Story

Read more

Schematics

Automatic Gas Reduction System-Circuit-Diagram

Code

Automatic Gas Reduction System

Arduino
#include <LiquidCrystal.h>

LiquidCrystal lcd(6, 7, 8, 9, 10, 11);
float gasPin = A0;
float gasLevel;
int ledPin = 2;
int buttonPin = 3;
int buzzPin = 4;
int buttonState;
int fan = 5;

void setup(){
  pinMode(ledPin, OUTPUT);
  pinMode(buttonPin, INPUT);
  pinMode(gasPin,INPUT);
  pinMode(fan,OUTPUT);
  Serial.begin(9600);
  lcd.begin(16, 2);
  lcd.setCursor(0,0);
  lcd.print("   Welcome");
  lcd.setCursor(0,2);
  lcd.print("   Youtube");
  delay(500);
  lcd.clear();
}

void loop(){
  // Read the value from gas sensor and button
  gasLevel = analogRead(gasPin);
  buttonState = digitalRead(buttonPin);
  
  // call the function for gas detection and button work
  gasDetected(gasLevel);
  exhaustFanOn(buttonState);
}

// Gas Leakage Detection & Automatic Alarm and Fan ON
void gasDetected(float gasLevel){
  if(gasLevel >= 300){
  	digitalWrite(buzzPin,HIGH);
    digitalWrite(ledPin,HIGH);
    digitalWrite(fan,HIGH);
    lcd.setCursor(0,0);
  	lcd.print("GAS:");
    lcd.print(gasLevel);
  	lcd.setCursor(0,2);
  	lcd.print("FAN ON");
  	delay(1000);
  	lcd.clear();
  }else{
  	digitalWrite(ledPin,LOW);
    digitalWrite(buzzPin,LOW);
    digitalWrite(fan,LOW);
    lcd.setCursor(0,0);
  	lcd.print("GAS:");
    lcd.print(gasLevel);
  	lcd.setCursor(0,2);
  	lcd.print("FAN OFF");
  	delay(1000);
  	lcd.clear();
  }
}

// Manually Exhaust FAN ON
void exhaustFanOn(int buttonState){
  if(buttonState == HIGH){
    digitalWrite(fan,HIGH);
    lcd.setCursor(0,0);
  	lcd.print("Button State:");
    lcd.print(buttonState);
    lcd.setCursor(0,2);
    lcd.print("FAN ON");
    delay(10000);
    lcd.clear();
  }
}

Credits

Khaled Md Saifullah

Khaled Md Saifullah

18 projects • 44 followers
🦸Tech Enthusiast 👨🏾‍💻Programmer 📳IoT Specialist

Comments