#include "DHT.h"
const int ledpin=13; // ledpin,flamepin and buzpin are not changed throughout the process
const int flamepin=2;
const int buzpin=11;
const int threshold=35;// sets threshold value for flame sensor
int flamesensvalue=0; // initialize flamesensor reading
#define DHTPIN 2
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
pinMode(ledpin,OUTPUT);
pinMode(flamepin,INPUT);
pinMode(buzpin,OUTPUT);
dht.begin();
}
void loop() {
flamesensvalue=(dht.readTemperature()); // reads analog data from flame sensor
if (flamesensvalue>=threshold) { // compares reading from flame sensor with the threshold value
digitalWrite(ledpin,HIGH); //turns on led and buzzer
tone(buzpin,100);
delay(2000); //stops program for 1 second
}
else{
digitalWrite(ledpin,LOW); //turns led off led and buzzer
noTone(buzpin);
}
Serial.println(flamesensvalue);
}