#include <Servo.h>
int flame_sensor = 2; // initializing pin 2 as the sensor output pin
int buzzer = 3;// initializing pin 3 as the buzzer output pin
int servoPin = 4; // initializing pin 4 as the servo output pin
int flame_detected; // state of sensor
Servo servol;
void setup()
{
Serial.begin(9600); // setting baud rate at 9600
pinMode(buzzer, OUTPUT); // declaring buzzer pin as output pin
pinMode(flame_sensor, INPUT); // declaring sensor pin as input pin for Arduino
servol.attach(servoPin);
servol.write(90);
delay(500);
}
void loop()
{
flame_detected = digitalRead(flame_sensor); // reading from the sensor
if (flame_detected == 1) // applying condition
{
digitalWrite(buzzer, LOW); // if state is high, then turn high the buzzer
servol.write(90);
}
else
{
digitalWrite(buzzer, HIGH); // otherwise turn it low
servol.write(0);
}
delay(100);
}