Arduino Project

Flame Monitor 2.0

Course Introduction

In this lesson, you’ll learn how to use a Flame Sensor, an I2C LCD Display, and the Arduino UNO R4 to monitor fire intensity. The LCD shows real-time readings, while LEDs and a buzzer provide visual and sound alerts for different flame levels.

Note

If this is your first time working with an Arduino project, we recommend downloading and reviewing the basic materials first.

1.1 Install Arduino IDE(Important)
1.2 Introduction of Arduino IDE

Required Components

In this project, we need the following components:

SN

COMPONENT INTRODUCTION

QUANTITY

PURCHASE LINK

1

Arduino UNO R4 Minima

1

2

USB Type-C cable

1

×

3

Breadboard

1

BUY

4

Wires

Several

5

Flame Sensor Module

1

6

Buzzer Modudle

1

7

I2C LCD 1602

1

8

Traffic Light LED

1

Wiring

6.png__PID:bc37a2a4-ac5d-4b60-a035-951bbb49c13f

Common Connections:

Flame Sensor Module
A0:
Connect to A0 on the Arduino.
GND: Connect to breadboard’s negative power bus.
VCC: Connect to breadboard’s red power bus.

Traffic light LED
R:
Connect to 5 on the Arduino.
Y: Connect to 4 on the Arduino.
G: Connect to 3 on the Arduino.
GND: Connect to breadboard’s negative power bus.

Buzzer Modudle
I/O:
Connect to 10 on the Arduino.
GND: Connect to breadboard’s negative power bus.
VCC: Connect to breadboard’s red power bus.

I2C LCD 1602
SDA:
Connect to A4 on the Arduino.
SCL: Connect to A5 on the Arduino.
GND: Connect to breadboard’s negative power bus.
VCC: Connect to breadboard’s red power bus.

Writing the Code

Note
You can copy this code into Arduino IDE.
To install the library, use the Arduino Library Manager and search for LiquidCrystal_I2C and install it.
Don’t forget to select the board(Arduino UNO R4 Minima/WIFI) and the correct port before clicking the Upload button.


#include 
#include 

// Define pin connections
const int sensorPin = A0;      // Analog pin connected to the flame sensor
const int redPin = 5;          // Red LED pin
const int yellowPin = 4;       // Yellow LED pin
const int greenPin = 3;        // Green LED pin
const int buzzerPin = 10;      // Buzzer pin

LiquidCrystal_I2C lcd(0x27, 16, 2);  // I2C LCD address and size

int flameValue = 0;  // Variable to store the flame sensor reading

void setup() {
  Serial.begin(9600);       // Initialize serial monitor for debugging
  lcd.init();               // Initialize LCD
  lcd.backlight();          // Turn on LCD backlight

  // Set pin modes
  pinMode(redPin, OUTPUT);
  pinMode(yellowPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);

  // Display startup message
  lcd.setCursor(0, 0);
  lcd.print("Flame Monitor");
  delay(1000);
}

void loop() {
  // Read analog value from flame sensor (0–1023)
  int rawValue = analogRead(sensorPin);

  // Invert value: when flame is closer, the value increases
  flameValue = 1023 - rawValue;

  // Print flame value to Serial Monitor
  Serial.print("Flame Sensor Value: ");
  Serial.println(flameValue);

  // Show value on LCD
  lcd.setCursor(0, 1);
  lcd.print("Value: ");
  lcd.print(flameValue);
  lcd.print("   ");  // Clear leftover digits

  // Flame detection logic
  if (flameValue < 250) {
    // No flame detected
    setLights(HIGH, LOW, LOW);  // Green ON, others OFF
    noTone(buzzerPin);          // Turn off buzzer
  }
  else if (flameValue < 450) {
    // Weak flame detected
    setLights(LOW, HIGH, LOW);  // Yellow ON
    tone(buzzerPin, 800, 200);  // Short beep sound
  }
  else {
    // Strong flame detected (danger)
    setLights(LOW, LOW, HIGH);  // Red ON
    tone(buzzerPin, 1000, 400); // Longer alarm sound
  }

  delay(200);  // Small delay for stability
}

// Helper function to control the three LEDs
void setLights(int greenState, int yellowState, int redState) {
  digitalWrite(greenPin, greenState);
  digitalWrite(yellowPin, yellowState);
  digitalWrite(redPin, redState);
}