Introduction
This experiment uses a flame detection sensor to detect the presence of fire or flame. It is often used in safety and alarm systems.

Components Needed
- Flame Detection Sensor
- Arduino (e.g., Uno, Nano)
- Jumper wires
Circuit Setup
- Connect the VCC pin of the flame sensor to the 5V pin on the Arduino.
- Connect the GND pin of the sensor to the GND pin on the Arduino.
- Connect the OUT pin of the sensor to a digital input pin (e.g., pin 2) on the Arduino.
Ensure all connections are correctly made and that the sensor is facing an appropriate light source.

Code for Flame Detection
Upload the following code to your Arduino to detect the presence of flame:
const int flamePin = 2; // Pin connected to the flame sensor
void setup() {
pinMode(flamePin, INPUT);
Serial.begin(9600); // Start serial communication
}
void loop() {
int flameState = digitalRead(flamePin); // Read the sensor
if (flameState == HIGH) {
Serial.println("Flame detected!");
} else {
Serial.println("No flame detected.");
}
delay(1000);
}
Explanation
The flame sensor detects light in the infrared range and outputs a HIGH signal when a flame is detected. The Arduino reads this signal and prints the result to the serial monitor.
Troubleshooting
- If the sensor is not detecting flames, check the wiring and ensure the sensor is within range of a flame source.
- If the sensor's response is inconsistent, adjust its sensitivity or check for interference from other light sources.