This circuit is designed to detect flames using multiple flame sensors and control a robot equipped with motors and a servo to extinguish the fire. The system uses an Arduino UNO microcontroller to read sensor data, control the motors, and activate a fire extinguisher mechanism.
Arduino UNO
KY-026 Flame Sensor
L293D Motor Driver
Hobby Gearmotor with 48:1 gearbox
Servo
1N4007 Rectifier Diode
5V connected to:
GND connected to:
A0 connected to:
A1 connected to:
A2 connected to:
D6 connected to:
D8 connected to:
D9 connected to:
D10 connected to:
D11 connected to:
VCC connected to:
GND connected to:
D0 connected to:
VCC connected to:
GND connected to:
D0 connected to:
VCC connected to:
GND connected to:
D0 connected to:
pin 5 connected to:
pin 6 connected to:
pin 7 connected to:
pin 8 connected to:
pin 10 connected to:
pin 9 connected to:
pin 12 connected to:
pin 11 connected to:
pin 1 connected to:
pin 2 connected to:
pin 1 connected to:
pin 2 connected to:
VCC connected to:
GND connected to:
PWM connected to:
#include <Servo.h>
// Define motor control pins
int motor1A = 8;
int motor1B = 9;
int motor2A = 10;
int motor2B = 11;
// Define flame sensor input pins
int flameSensor1 = A0;
int flameSensor2 = A1;
int flameSensor3 = A2;
// Define servo motor control pin
int servoPin = 6;
Servo nozzleServo;
// Define solenoid valve control pin
int solenoidPin = 12;
// Threshold for detecting fire
int threshold = 500;
void setup() {
// Initialize motor control pins as outputs
pinMode(motor1A, OUTPUT);
pinMode(motor1B, OUTPUT);
pinMode(motor2A, OUTPUT);
pinMode(motor2B, OUTPUT);
// Initialize flame sensor input pins
pinMode(flameSensor1, INPUT);
pinMode(flameSensor2, INPUT);
pinMode(flameSensor3, INPUT);
// Initialize solenoid pin as output
pinMode(solenoidPin, OUTPUT);
// Attach the servo motor
nozzleServo.attach(servoPin);
// Begin serial communication
Serial.begin(9600);
}
void loop() {
// Read values from flame sensors
int sensorValue1 = analogRead(flameSensor1);
int sensorValue2 = analogRead(flameSensor2);
int sensorValue3 = analogRead(flameSensor3);
// Print sensor values for debugging
Serial.print("Flame Sensor 1: ");
Serial.println(sensorValue1);
Serial.print("Flame Sensor 2: ");
Serial.println(sensorValue2);
Serial.print("Flame Sensor 3: ");
Serial.println(sensorValue3);
// Determine the direction based on sensor values
if (sensorValue1 > threshold) {
// Turn left towards the fire
turnLeft();
} else if (sensorValue2 > threshold) {
// Move forward towards the fire
moveForward();
} else if (sensorValue3 > threshold) {
// Turn right towards the fire
turnRight();
} else {
// Stop if no fire is detected
stopRobot();
}
// Check if any sensor detects fire
if (sensorValue1 > threshold || sensorValue2 > threshold || sensorValue3 > threshold) {
// Activate extinguisher
activateExtinguisher();
} else {
// Deactivate extinguisher
deactivateExtinguisher();
}
delay(500); // Delay for stability
}
// Function to move forward
void moveForward() {
digitalWrite(motor1A, HIGH);
digitalWrite(motor1B, LOW);
digitalWrite(motor2A, HIGH);
digitalWrite(motor2B, LOW);
}
// Function to turn left
void turnLeft() {
digitalWrite(motor1A, LOW);
digitalWrite(motor1B, HIGH);
digitalWrite(motor2A, HIGH);
digitalWrite(motor2B, LOW);
}
// Function to turn right
void turnRight() {
digitalWrite(motor1A, HIGH);
digitalWrite(motor1B, LOW);
digitalWrite(motor2A, LOW);
digitalWrite(motor2B, HIGH);
}
// Function to stop the robot
void stopRobot() {
digitalWrite(motor1A, LOW);
digitalWrite(motor1B, LOW);
digitalWrite(motor2A, LOW);
digitalWrite(motor2B, LOW);
}
// Function to activate the fire extinguisher
void activateExtinguisher() {
nozzleServo.write(90); // Adjust the servo to aim the nozzle
digitalWrite(solenoidPin, HIGH); // Open solenoid valve to release CO2
}
// Function to deactivate the fire extinguisher
void deactivateExtinguisher() {
digitalWrite(solenoidPin, LOW); // Close solenoid valve
}
``