Interfacing Flame Sensor with Arduino to Build a Fire Alarm System
Components Required
- Arduino Uno (any Arduino board can be used)
- Flame sensor
- LED
- Buzzer
- Resistor
- Jumper wires
int buzzer = 8;
int LED = 7;
int flame_sensor = 4;
int flame_detected;
void setup()
{
Serial.begin(9600);
pinMode(buzzer, OUTPUT);
pinMode(LED, OUTPUT);
pinMode(flame_sensor, INPUT);
}
void loop()
{
flame_detected = digitalRead(flame_sensor);
if (flame_detected == 1)
{
Serial.println("Flame detected...! take action immediately.");
digitalWrite(buzzer, HIGH);
digitalWrite(LED, HIGH);
delay(200);
digitalWrite(LED, LOW);
delay(200);
}
else
{
Serial.println("No flame detected. stay cool");
digitalWrite(buzzer, LOW);
digitalWrite(LED, LOW);
}
delay(1000);
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น