Project name :-Gas Sensor interface with Arduino
Component Required :
1> Gas sensor (MQ-2)
2> Led
3> Arduino
4> Jumper wires
5> PC
Project Objectives :
- To design the Automation system to detect the gas.
- To be able to aware human being from harmful gas
CIRCUIT DIAGRAM
fig:-Circuit Diagram
Connect analog pin of sensor to A0 of Arduino.
Connect GND pin of sensor to GND of Arduino
Connect VCC pin of sensor to 5V of Arduino
CODEint led = 13;
int sensor = A0;
void setup()
{
pinMode(led, OUTPUT);//Led is use as output.
pinMode(sensor, INPUT);//sensor is use as input.
Serial.begin(9600);
}
void loop()
{
int value = analogRead(sensor);//read the value of analog sensor
Serial.print("sensor value: ");
Serial.println(value);//print the value of sensor on serial monitor
if (analogSensor > 400)
{
digitalWrite(led, HIGH);
}
else
{
digitalWrite(led, LOW);
}
delay(100);
}
Upload the code &open the Serial monitor
When the sensor doesn't detected smoke then it gives value less than 400 so the led doesn't Glow.
When sensor detect smoke, it gives the value greater than 400 so the led will Glow