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:

  1. Understand how gas sensors detect changes in gas concentration.

  2. Simulate unavailable sensors in Tinkercad using equivalent components.

  3. Write Arduino code for sensing and alert systems.

  4. 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

  1. Potentiometer (Gas Sensor substitute)

    • One outer leg → 5V

    • Other outer leg → GND

    • Middle pin → A0

  2. LED (Alert Indicator)

    • Anode → Pin 9 (through 220 Ω resistor)

    • Cathode → GND

  3. 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

  1. The potentiometer simulates gas concentration.

    • Turning it toward higher values simulates gas leakage.

    • Lower values represent normal air.

  2. Arduino continuously reads analog values (0–1023).

  3. When the reading crosses the threshold (600), both LED and buzzer are activated.

  4. 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

  1. What type of gas sensors are commonly used in real systems?

  2. Why did we use a potentiometer in this simulation?

  3. What is the purpose of setting a threshold value?

  4. 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)

  1. Title

  2. Objective

  3. Components Used

  4. Circuit Diagram (Tinkercad screenshot)

  5. Arduino Code

  6. 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


Tinkercad Link

https://www.tinkercad.com/things/hpX9G3VOU82-labset-prog-8

Comments

  1. 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!

    Best Regards
    is kb bigger than mb

    ReplyDelete

Post a Comment

Popular posts from this blog