Lab set Program-8
8. Develop a program to detect the gas leakage in the surrounding environment.
Objective
To develop an Arduino-based system that detects gas leakage in the surrounding environment and alerts the user using LED and buzzer indicators.
(Simulated using a potentiometer as a gas sensor in Tinkercad.)
Learning Outcomes
After completing this experiment, students will be able to:
-
Understand how gas sensors detect changes in gas concentration.
-
Simulate unavailable sensors in Tinkercad using equivalent components.
-
Write Arduino code for sensing and alert systems.
-
Learn threshold-based control logic for safety applications.
Components (from Tinkercad Palette)
-
Arduino UNO board
-
Potentiometer (simulated gas sensor, connected to A0)
-
Red LED (gas leak alert)
-
Buzzer
-
220 Ω resistor (for LED)
-
Breadboard
-
Jumper wires
Circuit WiringT
-
Potentiometer (Gas Sensor substitute)
-
One outer leg → 5V
-
Other outer leg → GND
-
Middle pin → A0
-
-
LED (Alert Indicator)
-
Anode → Pin 9 (through 220 Ω resistor)
-
Cathode → GND
-
-
Buzzer
-
Positive → Pin 10
-
Negative → GND
Arduino Sketch
int gasSensor = A0; // Potentiometer as gas sensor
int ledPin = 9; // LED indicator
int buzzerPin = 10; // Buzzer
int gasValue = 0; // Variable to store sensor value
int threshold = 600; // Threshold for gas detection
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
gasValue = analogRead(gasSensor); // Read sensor value
Serial.print("Gas Sensor Value: ");
Serial.println(gasValue);
if (gasValue > threshold) { // If gas level exceeds threshold
digitalWrite(ledPin, HIGH);
digitalWrite(buzzerPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
digitalWrite(buzzerPin, LOW);
}
delay(500);
}
How It Works
-
The potentiometer simulates gas concentration.
-
Turning it toward higher values simulates gas leakage.
-
Lower values represent normal air.
-
-
Arduino continuously reads analog values (0–1023).
-
When the reading crosses the threshold (600), both LED and buzzer are activated.
-
When gas levels drop, the system resets to safe mode (LED and buzzer off).
Common Mistakes & Quick Fixes
| Issue | Cause | Fix |
|---|---|---|
| LED/Buzzer not responding | Incorrect pin or loose wiring | Check pin mapping and connections |
| Continuous buzzer sound | Threshold value too low | Increase threshold (e.g., 700) |
| No change in Serial values | Middle pin of potentiometer not connected to A0 | Recheck connections |
Viva / Check-Your-Understanding
-
What type of gas sensors are commonly used in real systems?
-
Why did we use a potentiometer in this simulation?
-
What is the purpose of setting a threshold value?
-
How can this system be improved for industrial applications?
Extensions (Mini-Tasks)
-
Add an LCD to display gas concentration levels.
-
Send a serial message or alert to a connected IoT dashboard.
-
Add a relay to automatically cut off power in case of leakage.
Lab Record (Suggested Headings)
-
Title
-
Objective
-
Components Used
-
Circuit Diagram (Tinkercad screenshot)
-
Arduino Code
-
Output / Simulation Results
Demo Tip (for Tinkercad)
-
Start Simulation.
-
Open Serial Monitor to watch gas values.
-
Slowly rotate the potentiometer knob → when value > 600, LED & buzzer turn ON.
-
Rotate back → both turn OFF

Great tutorial! It shows how to use an Arduino (simulated with a potentiometer as a gas sensor) to read analog values and trigger an LED + buzzer alarm when the gas level crosses a set threshold. The step-by-step wiring and code example make it easy to understand how gas leakage detection works in a basic IoT safety setup. Nice resource!
ReplyDeleteBest Regards
is kb bigger than mb