MisterBotBreak
Published

How to Use a Gas Sensor (MQ-2)

This project will show you how to use an MQ-2 gas sensor.

BeginnerProtip12 minutes737
How to Use a Gas Sensor (MQ-2)

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Grove - Gas Sensor(MQ2)
Seeed Grove - Gas Sensor(MQ2)
×1
5 mm LED: Red
5 mm LED: Red
×1
5 mm LED: Green
5 mm LED: Green
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Smoke detector

Arduino
void setup(){
  pinMode(13,1);
  pinMode(12,1);
  Serial.begin(115200);
}

void loop() {
  int Value = analogRead(A0);

  Serial.println("Analogic Value coming from the sensor : ");  
  Serial.println(Value);
  delay(100);

  if(value<400){
    digitalWrite(13,1);
  }
  else{
    digitalWrite(12,1);
  }
  delay(20);
}

Credits

MisterBotBreak

MisterBotBreak

31 projects • 59 followers
I love electronic and I make explanatory project on how to control sensors.

Comments

Add projectSign up / Login