MisterBotBreak
Published

How to Use a Gas Sensor (MQ-2)

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

BeginnerProtip12 minutes13,030
How to Use a Gas Sensor (MQ-2)

Things used in this project

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

48 projects • 151 followers
I love electronics and cats :D !

Comments