// Pin Definitions
const int gasSensorSimPin = 34; // Potentiometer simulating gas sensor
const int vibrationSensorSimPin = 35; // Potentiometer simulating vibration sensor
const int ledPin = 2 ; // LED pin for alerts
const int buzzerPin = 27; // Buzzer pin for alerts
// Thresholds
const int gasThreshold = 400; // Simulated gas detection threshold
const int vibrationThreshold = 500; // Simulated vibration threshold
void setup() {
// Initialize Serial Monitor
Serial.begin(115200);
// Configure Pins
pinMode(gasSensorSimPin, INPUT);
pinMode(vibrationSensorSimPin, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
// Initial States
digitalWrite(ledPin, LOW);
digitalWrite(buzzerPin, LOW);
Serial.println("Volcanic Eruption Detection System Initialized!");
}
void loop() {
// Read simulated sensor values
int gasValue = analogRead(gasSensorSimPin);
int vibrationValue = analogRead(vibrationSensorSimPin);
// Print sensor readings for debugging
Serial.print("Gas Sensor Value (Sim): ");
Serial.print(gasValue);
Serial.print(" | Vibration Sensor Value (Sim): ");
Serial.println(vibrationValue);
// Check conditions
if (gasValue > gasThreshold || vibrationValue > vibrationThreshold) {
// Trigger Alerts
Serial.println("Alert! Possible volcanic eruption detected!");
digitalWrite(ledPin, HIGH);
digitalWrite(buzzerPin, HIGH);
delay(1000); // Keep the alert on for 1 second
} else {
// No Alert
digitalWrite(ledPin, LOW);
digitalWrite(buzzerPin, LOW);
}
delay(500); // Small delay for sensor readings
}