Yellow → A5 to Gas sensor A0, Pin 12 to LED
Red → 5V to Gas sensor VCC
Black → GND to Gas sensor, LED cathode
Pin Configuration:
Arduino Analog Pin A5 → Gas sensor A0 output
Arduino Digital Pin 12 → LED anode (via 220Ω resistor)
Arduino 5V → Gas sensor VCC
Arduino GND → Gas sensor GND, LED cathode
#define led 12 // LED connected to pin 12
#define smoke A5 // Gas sensor connected to analog pin A5
int threshold = 400; // Threshold limit for smoke detection
void setup() {
pinMode(led, OUTPUT); // Set LED pin as output
pinMode(smoke, INPUT); // Set smoke sensor pin as input
Serial.begin(9600); // Initialize serial communication
Serial.println(\"Gas Sensor Module Initialized...\");
}
void loop() {
int value = analogRead(smoke); // Read analog sensor value
Serial.print(\"Sensor Reading: \");
Serial.println(value); // Display reading on Serial Monitor
if (value > threshold) {
digitalWrite(led, HIGH); // Turn ON LED if gas concentration exceeds threshold
Serial.println(\"Status: Smoke Detected!\");
} else {
digitalWrite(led, LOW); // Turn OFF LED if safe
Serial.println(\"Status: Air Clear.\");
}
delay(1000); // Wait for 1 second before next reading
}
Instruction Details
Wiring: Connect gas sensor VCC to 5V, GND to GND, A0 output to Analog Pin A5. Connect LED anode to Digital Pin 12 via 220Ω, cathode to GND.
Library: Not required (built-in).
Upload Code: Tools → Board → Arduino Uno. Tools → Port → select your COM port. Click Upload button.
View Output: Open Serial Monitor (Tools → Serial Monitor) at 9600 baud. Analog values and status display. Heat sensor 24–48 hours before first use. Detects LPG, CO, smoke.
How to Use
Connect the required components as per the Pin Configuration above
Open Arduino IDE and create a new sketch
Copy and paste the code above
Select your Arduino board and COM port from Tools menu
Click the Upload button to upload the code to your Arduino
Open Serial Monitor (if applicable) to see the output