const int smokeSensorPin = A0; // Analog pin for smoke sensor
const int heatSensorPin = A1; // Analog pin for heat sensor
const int flameSensorPin = A2; // Analog pin for flame sensor
const int ledPin = 13; // Digital pin for LED (alarm)
const int buzzerPin = 12; // Digital pin for Buzzer (alarm)
// Threshold values for fire detection
const int smokeThreshold = 600;
const int heatThreshold = 700;
const int flameThreshold = 500;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int smokeValue = analogRead(smokeSensorPin);
int heatValue = analogRead(heatSensorPin);
int flameValue = analogRead(flameSensorPin);
Serial.print("Smoke: ");
Serial.print(smokeValue);
Serial.print(" Heat: ");
Serial.print(heatValue);
Serial.print(" Flame: ");
Serial.println(flameValue);
// Check for fire conditions
if (smokeValue > smokeThreshold || heatValue > heatThreshold || flameValue > flameThreshold) {
digitalWrite(ledPin, HIGH); // Turn on LED
digitalWrite(buzzerPin, HIGH);// Turn on Buzzer
} else {
digitalWrite(ledPin, LOW); // Turn off LED
digitalWrite(buzzerPin, LOW);// Turn off Buzzer
}
delay(1000); // Delay between sensor readings
}