AJAY-Negasonic
Published © GPL3+

MQ-2 Gas Sensor Arduino

I have worked on MQ-2 gas sensor (FC-22) powered and interfaced it with an Arduino Uno.

IntermediateFull instructions provided1 hour51
MQ-2 Gas Sensor Arduino

Things used in this project

Hardware components

Grove - Gas Sensor(MQ2)
Seeed Grove - Gas Sensor(MQ2)
×1
Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
Buzzer
Buzzer
×1
LED (generic)
LED (generic)
×2
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

schematic

Capture plf2nxch0s

PIN diagram MQ2

2 bfzmsvieba

Code

Code snippet #1

Plain text
******
 
 All the resources for this project:
 https://www.electromaniaweb.wordpress.com 
https://www.arduino.cc

*******/

int LED1 = 12;
int LED2 = 11;
int buzzer = 10;
int smokeA0 = A5;
int sensorThreshold = 400;

void setup() {
  pinMode(LED1, OUTPUT);
  pinMode(greenLed, OUTPUT);
  pinMode(buzzer, OUTPUT);
  pinMode(smokeA0, INPUT);
  Serial.begin(9600);
}

void loop() {
  int analogSensor = analogRead(smokeA0);

  Serial.print("Pin A0: ");
  Serial.println(analogSensor);
  // Checks if it has reached the threshold value
  if (analogSensor > sensorThreshold)
  {
    digitalWrite(LED1, HIGH);
    digitalWrite(LED2, LOW);
    tone(buzzer, 1000, 200);
  }
  else
  {
    digitalWrite(LED1, LOW);
    digitalWrite(LED2, HIGH);
    noTone(buzzer);
  }
  delay(100);
}

CODE

Arduino
All the resources for this project:
 https://www.electromaniaweb.wordpress.com 
https://www.arduino.cc

*******/

int LED1 = 12;
int LED2 = 11;
int buzzer = 10;
int smokeA0 = A5;
int sensorThreshold = 400;

void setup() {
  pinMode(LED1, OUTPUT);
  pinMode(greenLed, OUTPUT);
  pinMode(buzzer, OUTPUT);
  pinMode(smokeA0, INPUT);
  Serial.begin(9600);
}

void loop() {
  int analogSensor = analogRead(smokeA0);

  Serial.print("Pin A0: ");
  Serial.println(analogSensor);
  // Checks if it has reached the threshold value
  if (analogSensor > sensorThreshold)
  {
    digitalWrite(LED1, HIGH);
    digitalWrite(LED2, LOW);
    tone(buzzer, 1000, 200);
  }
  else
  {
    digitalWrite(LED1, LOW);
    digitalWrite(LED2, HIGH);
    noTone(buzzer);
  }
  delay(100);
}

Credits

AJAY-Negasonic

AJAY-Negasonic

9 projects • 0 followers
I'm an Electrical Undergrad. 21. I often make projects on Arduino and Raspberrypi platform. Active blogger on Analog concepts on my website.

Comments

Add projectSign up / Login