Introduction
In this article I will explain how to detect gas using Arduino Mega. The gas sensor can easily find gas leaking at a place. When the gas is detected it can measure the range of the gas sensor.
-
Arduino Mega 2560
-
Gas Sensor
-
Buzzer
-
Bread Board
-
Led
-
Hookup wires.
Connection:

Figure 1: Gas Sensor
-
Take the Output pin to the Analog pin of the A0 in the Arduino Mega board.
-
Take the Vcc pin to the +5v of the ArduinoMega board.
-
Take the Gnd pin to the Gnd of the ArduinoMega board.
Step 2: Connection from the LED to the Arduino Mega2560
-
Positive pin = 10;
-
Negative pin = Gnd;
Step 3: Connection from the Buzzer to the Arduino Mega2560
-
Take the positive pin and connect to the Digital pin of 05 to the Arduino Mega board.
-
Take the negative pin and connect to the Gnd of the ArduinoMega board.
Programming:
- const int sensorpin = A0; // sensor output pin to Arduino analog A0 pin
- int led = 10;
- int buzzer = 5;
- int sensorValue = 0;
- void setup()
- {
- pinMode(led, OUTPUT);
- pinMode(buzzer, OUTPUT);
- Serial.begin(9600); //Initialize serial port - 9600 bps
- }
- void loop()
- {
- Serial.println("Welcome to c#corner");
- sensorValue = analogRead(sensorpin);
- Serial.println(sensorValue);
- if (sensorValue < 100)
- {
- Serial.println("LPG Value");
- Serial.println("LED on");
- digitalWrite(led, HIGH);
- digitalWrite(buzzer, HIGH);
- delay(1000);
- }
- digitalWrite(led, LOW);
- digitalWrite(buzzer, LOW);
- delay(sensorValue);
- }
Explanation:
-
When the gas is detected the LED will be ON and the Buzzer also produced the sound.
-
Then we can see the reading in the serial monitor.
-
When the Gas is detected the LED can be HIGH.
Output:
Serial Monitor:

Figure 2: serial Monitor Display
Output:

Figure 3: Output
Read more articles on Arduino:


Sr KarthigaPosted Feb 29, 2016, 2:45 PM EST
thank you asfend sir
Sr KarthigaPosted Feb 29, 2016, 2:45 PM EST
thank you jithil sir
Asfend YarPosted Feb 29, 2016, 9:22 AM EST
nice
Jithil JohnPosted Feb 15, 2016, 5:55 PM EST
Good one
Sr KarthigaPosted Feb 15, 2016, 2:16 AM EST
Thank you raja sir
Sr KarthigaPosted Feb 15, 2016, 2:16 AM EST
Thank you sibeesh sir
Sr KarthigaPosted Feb 15, 2016, 2:16 AM EST
Thank you gowtham sir
Sr KarthigaPosted Feb 15, 2016, 2:15 AM EST
Thank you santhakumar sir
Raja TPosted Feb 14, 2016, 10:05 PM EST
Nice,Thanks for sharing
Sibeesh VenuTOP 100Posted Feb 14, 2016, 7:36 PM EST
Nice Share
Gowtham KTOP 100Posted Feb 13, 2016, 6:31 AM EST
Nice share
Santhakumar MunuswamyPosted Feb 12, 2016, 9:58 PM EST
Thanks for nice share
Sr KarthigaPosted Feb 12, 2016, 9:32 PM EST
Thank you Pramod sir
Pramod ThakurPosted Feb 12, 2016, 7:30 PM EST
Good one..
Sr KarthigaPosted Feb 12, 2016, 7:24 PM EST
Thanks Shubham sir
Shubham KumarPosted Feb 12, 2016, 6:41 PM EST
nice
Sr KarthigaPosted Feb 12, 2016, 2:36 PM EST
Thank you kumaresh sir
Kumaresh RajalingamPosted Feb 12, 2016, 6:42 AM EST
Nice share