Hackster is hosting Hackster Holidays, Finale: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Tuesday!Stream Hackster Holidays, Finale on Tuesday!
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,038
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
48 projects • 152 followers
I love electronics and cats :D !

Comments