For part of the final project for my first-year engineering class, I had to design a circuit that would extinguish a flame upon sensing it. To accomplish this task, I used a flame sensor in connection to a relay and a fan. The flame sensor can detect both flames and UV light as well as being able to output both digital and analog signals. I used the analog output of the sensor for this circuit. Upon sensing a flame or IR light source, it sends a signal to the Arduino. Then a signal is sent to the relay. A relay is a switch controlled by an electromagnet, so once it receives a signal, it switches to power on the fan. Here is a video showcasing the circuit in action.
Here is the code for the circuit and a diagram of the fan and the relay.
Flame Sensor Code
void setup() {
pinMode(A0, INPUT);
Serial.begin(9600); pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
sensorValue = analogRead(A0);
Serial.println(sensorValue);
delay(10);
if(sensorValue <= 700){ digitalWrite(13, HIGH);
}
else{
digitalWrite(13, LOW);
}
}