Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Controlled Fire Extinguishing Robot with Servo-Activated Water Pump

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled Fire Extinguishing Robot with Servo-Activated Water Pump

Circuit Documentation

Summary

This circuit is designed to control a servo motor, multiple DC motors, a water pump, and flame sensors using an Arduino UNO microcontroller. The circuit includes a motor driver module (L293D) for controlling the water pump, another motor driver (L298N) for controlling the DC motors, and flame sensors for detecting fire. The system is powered by a 12V battery, and a rocker switch is used to control the power supply to the circuit. The Arduino UNO reads inputs from the flame sensors and controls the motors and the water pump accordingly to put off detected fires.

Component List

Arduino UNO

Servo

L293D Motor Driver Module

L298N DC Motor Driver

KY-026 Flame Sensor

12V Battery

5V Mini Water Pump

DC Motor

Rocker Switch

Wiring Details

Arduino UNO

Servo

L293D Motor Driver Module

L298N DC Motor Driver

KY-026 Flame Sensor

12V Battery

5V Mini Water Pump

DC Motor

Rocker Switch

Documented Code

#include <Servo.h>  // Include the Servo library

Servo myservo;  // Create a servo object

int pos = 0;  // Variable to store the servo position

int motor_speed = 70;  // Set the motor speed

boolean fire = false;  // Flag for fire detection

// Define sensor and motor control pins
#define Left 9
#define Right 10
#define Forward 8
#define LM1 2
#define LM2 7
#define RM1 4
#define RM2 12
#define pump 6

void setup() {
  // Initialize all the sensor and motor control 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);

  // Set initial motor speed
  analogWrite(3, motor_speed);
  analogWrite(5, motor_speed);

  // Attach the servo to pin D11 and set initial position
  myservo.attach(11);
  myservo.write(90);
}

// Function to put off fire
void put_off_fire() {
  delay(500);
  // Activate all motors and the water pump
  digitalWrite(LM1, HIGH);
  digitalWrite(LM2, HIGH);
  digitalWrite(RM1, HIGH);
  digitalWrite(RM2, HIGH);
  digitalWrite(pump, HIGH);

  delay(500);

  // Sweep the servo from 50 to 130 degrees
  for (pos = 50; pos <= 130; pos += 1) {
    myservo.write(pos);
    delay(10);
  }

  // Sweep the servo back from 130 to 50 degrees
  for (pos = 130; pos >= 50; pos -= 1) {
    myservo.write(pos);
    delay(10);
  }

  // Turn off the water pump and reset the servo position
  digitalWrite(pump, LOW);
  myservo.write(90);
  fire = false;
}

void loop() {
  // Reset the servo position
  myservo.write(90);

  // Check the flame sensors and control the motors accordingly
  if (digitalRead(Left) == 1 && digitalRead(Right) == 1 && digitalRead(Forward) == 1) {
    digitalWrite(LM1, HIGH);
    digitalWrite(LM2, HIGH);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, HIGH);
  } else if (digitalRead(Forward) == 0) {
    digitalWrite(LM1, HIGH);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, LOW);
    fire = true;
  } else if (digitalRead(Left) == 0) {
    digitalWrite(LM1, HIGH);
    digitalWrite(LM2, LOW);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, HIGH);
  } else if (digitalRead(Right) == 0) {
    digitalWrite(LM1, HIGH);
    digitalWrite(LM2, HIGH);
    digitalWrite(RM1, HIGH);
    digitalWrite(RM2, LOW);
  }

  delay(300);  // Adjust this value to change the response time

  // If fire is detected, activate the fire extinguishing routine
  while (fire == true) {
    put_off_fire();
  }
}

This code controls the servo and motors based on the input from the flame sensors. When a fire is detected, it activates the water pump and sweeps the servo to put off the fire. The motors are controlled to move the system towards the fire.