In this material, a project of a homemade flame detector based on Arduino and a KY-026 sensor will be considered. This is a fairly multifunctional device that can be applied in various fields.
For example, you can use it to alert you when your race car's brakes are getting hot. It can also be used in many things, such as cut-off circuits for fuel lines, propane or natural gas lines, and fire extinguishing system activation devices. It can also alert you to flame in some industrial applications.
The wiring diagram for the Arduino based fire detector components is shown below.
The program code is as follows.
int Relay = 7;
int Buzzer = 5;
int RedLed = 6 ;
int GreenLed = 8 ;
int Digitalpin = 3;
int Analoogpin = A3;
int val ;
float sensor;
int tones[] = {261, 277, 293, 311, 329, 349, 369, 392, 415, 440, 466, 493, 523 ,554};
void setup ()
{
Serial.begin(9600);
pinMode (Relay, OUTPUT) ;
digitalWrite(Relay, LOW);
pinMode (Buzzer, OUTPUT) ;
digitalWrite(Buzzer, LOW);
pinMode (RedLed, OUTPUT) ;
pinMode (GreenLed, OUTPUT) ;
pinMode (Digitalpin, INPUT) ;
pinMode (Analoogpin, INPUT) ;
//+++++++++++++++++++++++++++++++++++++++++++
for (int i = 0; i < Buzzer; i++) {
}
}
void loop ()
{
sensor = analogRead(Analoogpin);
Serial.println(sensor);
val = digitalRead (Digitalpin) ;
if (val == HIGH)
{
digitalWrite (RedLed, HIGH);
digitalWrite(Buzzer, HIGH);
tone(Buzzer, tones[6]);
delay (100);
digitalWrite (RedLed, LOW);
digitalWrite(Buzzer, LOW);
noTone(Buzzer);
delay (100);
digitalWrite (RedLed, HIGH);
digitalWrite(Buzzer, HIGH);
tone(Buzzer, tones[1]);
delay (100);
digitalWrite (RedLed, LOW);
digitalWrite(Buzzer, LOW);
noTone(Buzzer);
delay (100);
digitalWrite(Relay, HIGH);
// digitalWrite(Relay, HIGH);
delay (100);
digitalWrite (RedLed, HIGH);
digitalWrite (GreenLed, LOW);
digitalWrite(Buzzer, HIGH);
tone(Buzzer, tones[3]);
delay (100);
}
else
{
digitalWrite (GreenLed, HIGH);
digitalWrite (RedLed, HIGH);
delay(10);
digitalWrite (RedLed, LOW);
digitalWrite(Buzzer, HIGH);
noTone(Buzzer);
// digitalWrite(Relay, HIGH);
}
delay(1000);
}