Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

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

Image 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

  • Microcontroller board based on the ATmega328P
  • Used as the central controller for the circuit

Servo

  • A motor capable of precise control of angular position
  • Used for sweeping actions in the circuit

L293D Motor Driver Module

  • A motor driver capable of driving a small DC motor or a stepper motor
  • Used to control the water pump in the circuit

L298N DC Motor Driver

  • A dual H-bridge motor driver capable of driving two DC motors or one stepper motor
  • Used to control the DC motors in the circuit

KY-026 Flame Sensor

  • A sensor for detecting fire or flame
  • Multiple instances are used for fire detection from different directions

12V Battery

  • A power source for the circuit
  • Provides the necessary voltage for the motor drivers and the motors

5V Mini Water Pump

  • A pump used for water flow
  • Activated to put off fires detected by the flame sensors

DC Motor

  • A simple electric motor that runs on direct current electricity
  • Multiple instances are used for movement and actions in the circuit

Rocker Switch

  • A switch to control the connection of the power supply
  • Used to turn the circuit on and off

Wiring Details

Arduino UNO

  • 5V pin connected to various components for power
  • GND pin connected to various components for ground
  • Digital pins D2 to D12 used for controlling motors and reading sensor inputs

Servo

  • VCC connected to Arduino's 5V
  • GND connected to Arduino's GND
  • Pulse connected to Arduino's D11

L293D Motor Driver Module

  • EN1, 5V connected to Arduino's 5V
  • GND connected to Arduino's GND and 12V Battery's negative terminal
  • IN1, IN2 connected to Arduino's D6 and D7
  • M1 connected to the 5V Mini Water Pump

L298N DC Motor Driver

  • 5V connected to Arduino's Vin
  • GND connected to Arduino's GND and 12V Battery's negative terminal
  • IN1, IN2, IN3, IN4 connected to Arduino's D4, D5, D7, D12
  • ENA, ENB connected to Arduino's D3, D5
  • OUT1, OUT2, OUT3, OUT4 connected to DC Motors

KY-026 Flame Sensor

  • VCC connected to Arduino's 5V
  • GND connected to Arduino's GND
  • D0 connected to Arduino's D8, D9, D10

12V Battery

  • Positive terminal connected to the motor drivers and the rocker switch
  • Negative terminal connected to the motor drivers and Arduino's GND

5V Mini Water Pump

  • Positive and negative pins connected to L293D Motor Driver Module's M1

DC Motor

  • Pins connected to L298N DC Motor Driver's OUT1, OUT2, OUT3, OUT4

Rocker Switch

  • Input connected to the 12V Battery's positive terminal
  • Output connected to the motor drivers' 12V input

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.