The circuit described in the provided inputs consists of an Arduino UNO microcontroller interfaced with a flame sensor, a piezo buzzer, and a red two-pin LED. The flame sensor is used to detect the presence of a flame, and upon detection, the Arduino activates the LED and the piezo buzzer as indicators. The Arduino UNO reads the analog value from the flame sensor and controls the LED and buzzer based on the sensor's output.
#include<SoftwareSerial.h>
int sensorPin = A0; // select the input pin for the LDR
int sensorValue = 0; // variable to store the value coming from the sensor
int led = 9; // Output pin for LED
int buzzer = 12; // Output pin for Buzzer
void setup() {
// declare the ledPin and buzzer as an OUTPUT:
pinMode(led, OUTPUT);
pinMode(buzzer, OUTPUT);
Serial.begin(9600);
}
void loop() {
Serial.println("Welcome to TechPonder Flame Sensor Tutorial");
sensorValue = analogRead(sensorPin);
Serial.println(sensorValue);
if (sensorValue < 100) {
Serial.println("Fire Detected");
Serial.println("LED on");
digitalWrite(led, HIGH);
digitalWrite(buzzer, HIGH);
delay(1000);
}
digitalWrite(led, LOW);
digitalWrite(buzzer, LOW);
delay(sensorValue);
}
Filename: sketch.ino
Description: This code initializes the Arduino UNO to read the analog value from the flame sensor connected to pin A0. If the sensor value is below 100, indicating the presence of a flame, the Arduino sets the LED (connected to pin D9) and the buzzer (connected to pin D12) to HIGH, turning them on. After a delay, both the LED and buzzer are turned off, and the cycle repeats with a delay based on the sensor value.