0% found this document useful (0 votes)
22 views5 pages

New Code For Fire Fighting Robot

This document contains an Arduino program that controls a robot equipped with a fire detection and extinguishing system using a MLX90614 temperature sensor and a flame sensor. The robot can navigate based on movement sensors and will activate a pump and servo to extinguish a fire when a certain temperature or flame is detected. The code includes setup for various pins, sensor readings, and motor control logic for the robot's movement and fire response actions.

Uploaded by

janannianbalagan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views5 pages

New Code For Fire Fighting Robot

This document contains an Arduino program that controls a robot equipped with a fire detection and extinguishing system using a MLX90614 temperature sensor and a flame sensor. The robot can navigate based on movement sensors and will activate a pump and servo to extinguish a fire when a certain temperature or flame is detected. The code includes setup for various pins, sensor readings, and motor control logic for the robot's movement and fire response actions.

Uploaded by

janannianbalagan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

#include <Wire.

h>

#include <Adafruit_MLX90614.h>

#include <Servo.h>

// Pin Definitions

#define Left 8

#define Right 9

#define Forward 10

#define LM1 2

#define LM2 3

#define RM1 4

#define RM2 5

#define pump 6

#define FLAME_SENSOR_ANALOG_PIN A0 // Flame sensor (analog)

#define RELAY_PIN 7 // Relay pin to activate fire extinguishing mechanism

// MLX90614 Sensor and Servo Setup

Adafruit_MLX90614 mlx;

Servo myservo;

void setup() {

// Initialize pins

pinMode(Left, INPUT);

pinMode(Right, INPUT);

pinMode(Forward, INPUT);

pinMode(LM1, OUTPUT);

pinMode(LM2, OUTPUT);

pinMode(RM1, OUTPUT);

pinMode(RM2, OUTPUT);
pinMode(pump, OUTPUT);

pinMode(RELAY_PIN, OUTPUT);

// Initialize sensors and servo

mlx.begin();

myservo.attach(9); // Servo control pin (PWM)

myservo.write(90); // Initial servo position

// Start Serial for debugging

Serial.begin(9600);

void sweepServo() {

// Sweep servo to simulate fire extinguishing action

for (int pos = 50; pos <= 130; pos++) {

myservo.write(pos);

delay(10);

for (int pos = 130; pos >= 50; pos--) {

myservo.write(pos);

delay(10);

void putOffFire() {

// Stop motors and activate the pump for extinguishing

digitalWrite(LM1, LOW);

digitalWrite(LM2, LOW);

digitalWrite(RM1, LOW);
digitalWrite(RM2, LOW);

digitalWrite(pump, HIGH); // Activate pump (fire extinguisher)

digitalWrite(RELAY_PIN, HIGH); // Activate relay for additional extinguishing

sweepServo(); // Sweep the servo while extinguishing fire

digitalWrite(pump, LOW); // Deactivate pump

digitalWrite(RELAY_PIN, LOW); // Deactivate relay

void loop() {

// Read temperature from MLX90614 sensor

double temp = mlx.readObjectTempC();

Serial.print("Object Temperature: ");

Serial.print(temp);

Serial.println(" *C");

// Check flame sensor data

int flameSensorValue = analogRead(FLAME_SENSOR_ANALOG_PIN); // Read flame sensor analog value

// If the temperature is above a threshold or a flame is detected, activate fire extinguishing

if (temp > 37.0 || flameSensorValue > 500) { // Adjust threshold based on testing

Serial.println("Fire Detected! Activating fire extinguishing.");

putOffFire();

} else {

// Check the movement sensors for the robot (optional for robot navigation)

int leftSensor = digitalRead(Left);

int rightSensor = digitalRead(Right);

int forwardSensor = digitalRead(Forward);


// If no fire is detected, the robot moves forward (example)

if (leftSensor && rightSensor && forwardSensor) {

digitalWrite(LM1, HIGH);

digitalWrite(LM2, HIGH);

digitalWrite(RM1, HIGH);

digitalWrite(RM2, HIGH);

} else {

// Stop and adjust movement based on sensor inputs

digitalWrite(LM1, HIGH);

digitalWrite(LM2, LOW);

digitalWrite(RM1, HIGH);

digitalWrite(RM2, LOW);

if (leftSensor == LOW) {

// Turn left

digitalWrite(LM1, HIGH);

digitalWrite(LM2, LOW);

digitalWrite(RM1, HIGH);

digitalWrite(RM2, HIGH);

if (rightSensor == LOW) {

// Turn right

digitalWrite(LM1, HIGH);

digitalWrite(LM2, HIGH);

digitalWrite(RM1, HIGH);

digitalWrite(RM2, LOW);

}
}

delay(100); // Small delay to prevent excessive sensor readings

You might also like