Hello Friends, Welcome to Official Website of Mr. Modify GamerzContact Me
Subscribe on Youtubeyoutube.com/@Mr.ModifyGamerz
Follow on Instagraminstagram.com/itz_mr269
Eye Comfort Full Screen Original Screen
Posts

Gas Leakage Detector

#include <Servo.h> 
Servo servo;

int gas = A0;
int green1 = 2;
int green2 = 4;
int green3 = 7;
int yellow1 = 8;
int yellow2 = 9;
int red1 = 10;
int red2 = 11;
int buzz = 5;
int motor = 3;
int pp = A1;

void setup() {
  pinMode(gas, INPUT);
  pinMode(green1, OUTPUT);
  pinMode(green2, OUTPUT);
  pinMode(green3, OUTPUT);
  pinMode(yellow1, OUTPUT);
  pinMode(yellow2, OUTPUT);
  pinMode(red1, OUTPUT);
  pinMode(red2, OUTPUT);
  pinMode(buzz, OUTPUT);
  pinMode(motor, OUTPUT);
  servo.attach(6);

  Serial.begin(9600);
}

void loop() {
  int pv = analogRead(pp);                          
  int range = map(pv, 0, 1023, 180, 600);            
  int gasValue = analogRead(gas);                    

  
  Serial.print("gas- ");
  Serial.print(gasValue);
  Serial.print("  threshold base- ");
  Serial.println(range);

  delay(200);

  digitalWrite(green1, LOW);
  digitalWrite(green2, LOW);
  digitalWrite(green3, LOW);
  digitalWrite(yellow1, LOW);
  digitalWrite(yellow2, LOW);
  digitalWrite(red1, LOW);
  digitalWrite(red2, LOW);
  digitalWrite(buzz, LOW);
  digitalWrite(motor, LOW);


  if (gasValue > range) {
    digitalWrite(green1, HIGH);
    servo.write(0);
  }
  if (gasValue > range + 70) {
    digitalWrite(green2, HIGH);
  }
  if (gasValue > range + 100) {
    digitalWrite(green3, HIGH);
  }
  if (gasValue > range + 130) {
    digitalWrite(yellow1, HIGH);
  }
  if (gasValue > range + 160) {
    digitalWrite(yellow2, HIGH);
  }
  if (gasValue > range + 220) {
    digitalWrite(red1, HIGH);
    digitalWrite(buzz, HIGH);
    digitalWrite(motor, HIGH);
    servo.write(90);
  }
  if (gasValue > range + 240) {
    digitalWrite(red2, HIGH);
  }

  delay(500);
}

Post a Comment

Cookies Policy
We can ensure your information is completely secure and private on our website and is not leaked. Google collects minor cookies for your better experience and we are not responsible for it.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.