STEP 1 / 6ARDUINO

Arduino Based Autonomous Fire Fighting Robot

30 1. Arduino Based Autonomous Fire Fighting Robot Firefighters can independently detect fires with this sophisticated firefighting robotic system. Fire fighters face an increasing risk o…

Arduino Uno autonomous fire fighting robot with HC-SR04 ultrasonic sensor, L293D motor driver, flame sensor, nozzle servo, water tank and 12V pump
PROJECT#301
TRACKArduino
PARTS17
STAGES06
STEP 1 / 6 · Overview

Know the mission before touching a wire.

Understand what you are making, prepare the right tools, and make the workbench safe.

01

Project details

Arduino Based Autonomous Fire Fighting Robot is a arduino project. 30 1. Arduino Based Autonomous Fire Fighting Robot Firefighters can independently detect fires with this sophisticated firefighting robotic system. Fire fighters face an increasing risk o…

Source pages
592-594
Named parts
17
Build goal
Working, tested prototype
02

Tools you need

  • Digital multimeter
  • Wire stripper and side cutters
  • Soldering iron with a fine tip
  • Current-limited bench supply
  • Computer with a data-capable USB cable

Use eye protection, good lighting, and a clean insulated surface throughout the build.

03

Safety precautions

  • Disconnect every power source before changing a connection.
  • Check component polarity, pinout, and supply voltage twice.
  • Use a current limit for the first power-up.
  • Keep liquids, loose metal, and uninsulated wires away from the bench.
Ready to continue?
STEP 2 / 6 · Parts library

Gather, identify, and understand every part.

Use the standardized inventory, then open What's this? to learn each part's role, advantages, limitations, handling, and specifications.

NAMED PROJECT INVENTORY17 PART LINES
PARTTYPEQTYREADY
MArduino Uno R3MODULE1
What's this?Image, role, pros, cons, handling & specifications
Arduino fire fighting robot components including Arduino Uno, HC-SR04 sensor, two SG90 servos, L293D driver, flame sensor, geared motors, water pump and chassisMODULE LEARNING VIEW

Arduino Uno R3

A programmable controller that reads inputs, makes decisions, and drives the project's outputs.

What it does here

It is the control centre and must use the documented board, pin map, supply, and logic level.

Buy / compare this part

Advantages

  • Reprogrammable and reusable
  • Large learning ecosystem
  • Complex behaviour remains changeable

Limitations

  • GPIO voltage and current are limited
  • Some pins affect boot or communication
  • Loads normally need a driver

Handling

  • Disconnect power before rewiring
  • Avoid static discharge
  • Never power motors, relays, or pumps directly from GPIO

Specifications to verify

  • Use the exact model, value, package, and rating listed for Arduino Uno R3; similar-looking parts are not always interchangeable.
  • Confirm operating voltage, logic level, pinout, memory, USB interface, and maximum GPIO current.
MHC-SR04 ultrasonic distance sensorMODULE1
What's this?Image, role, pros, cons, handling & specifications
Arduino fire fighting robot components including Arduino Uno, HC-SR04 sensor, two SG90 servos, L293D driver, flame sensor, geared motors, water pump and chassisMODULE LEARNING VIEW

HC-SR04 ultrasonic distance sensor

A sensor converts a physical condition into an electrical signal the circuit can measure.

What it does here

It provides project input as an analogue, digital, resistive, frequency, or calibrated signal.

Buy / compare this part

Advantages

  • Adds real-world awareness
  • Can usually be tested independently
  • Often supports calibration

Limitations

  • Readings can drift
  • Placement affects results
  • Some sensors need warm-up or calibration

Handling

  • Protect the sensing surface
  • Observe supply voltage and polarity
  • Keep signal leads away from noisy power wiring

Specifications to verify

  • Use the exact model, value, package, and rating listed for HC-SR04 ultrasonic distance sensor; similar-looking parts are not always interchangeable.
  • Confirm supply range, output type, measurement range, accuracy, response time, and pin order.
MAnalog infrared flame sensor moduleMODULE1
What's this?Image, role, pros, cons, handling & specifications
Arduino fire fighting robot components including Arduino Uno, HC-SR04 sensor, two SG90 servos, L293D driver, flame sensor, geared motors, water pump and chassisMODULE LEARNING VIEW

Analog infrared flame sensor module

A sensor converts a physical condition into an electrical signal the circuit can measure.

What it does here

It provides project input as an analogue, digital, resistive, frequency, or calibrated signal.

Buy / compare this part

Advantages

  • Adds real-world awareness
  • Can usually be tested independently
  • Often supports calibration

Limitations

  • Readings can drift
  • Placement affects results
  • Some sensors need warm-up or calibration

Handling

  • Protect the sensing surface
  • Observe supply voltage and polarity
  • Keep signal leads away from noisy power wiring

Specifications to verify

  • Use the exact model, value, package, and rating listed for Analog infrared flame sensor module; similar-looking parts are not always interchangeable.
  • Confirm supply range, output type, measurement range, accuracy, response time, and pin order.
PL293D dual H-bridge motor driver ICPART1
What's this?Image, role, pros, cons, handling & specifications
Arduino fire fighting robot components including Arduino Uno, HC-SR04 sensor, two SG90 servos, L293D driver, flame sensor, geared motors, water pump and chassisPART LEARNING VIEW

L293D dual H-bridge motor driver IC

An output component turns an electrical control signal into light, sound, motion, switching, or displayed information.

What it does here

It presents the circuit result or acts on the physical world.

Buy / compare this part

Advantages

  • Makes system state visible
  • Can be tested separately
  • Supports clear troubleshooting

Limitations

  • Loads may exceed controller current
  • Polarity or driver direction can matter
  • Inductive loads create voltage spikes

Handling

  • Use the documented driver stage
  • Check polarity and load current
  • Add flyback protection for inductive loads

Specifications to verify

  • Use the exact model, value, package, and rating listed for L293D dual H-bridge motor driver IC; similar-looking parts are not always interchangeable.
  • Confirm voltage, current, polarity, interface, driver requirements, and duty cycle.
PTwo DC geared drive motorsPART1
What's this?Image, role, pros, cons, handling & specifications
Arduino fire fighting robot components including Arduino Uno, HC-SR04 sensor, two SG90 servos, L293D driver, flame sensor, geared motors, water pump and chassisPART LEARNING VIEW

Two DC geared drive motors

A named project component whose exact role is defined by the source circuit and build guide.

What it does here

It performs a documented electrical, control, interface, or construction function in this project.

Buy / compare this part

Advantages

  • Selected for this project
  • Can be checked independently
  • Supports modular troubleshooting

Limitations

  • Substitutes may differ
  • Generic names can hide variants
  • Pinouts and ratings vary

Handling

  • Compare the received part with the source
  • Keep it labelled
  • Do not force connectors or adjusters

Specifications to verify

  • Use the exact model, value, package, and rating listed for Two DC geared drive motors; similar-looking parts are not always interchangeable.
  • Confirm dimensions, ratings, connection method, polarity, and environmental limits.
PTwo hobby servo motors - obstacle scanner and water nozzlePART1
What's this?Image, role, pros, cons, handling & specifications
Arduino fire fighting robot components including Arduino Uno, HC-SR04 sensor, two SG90 servos, L293D driver, flame sensor, geared motors, water pump and chassisPART LEARNING VIEW

Two hobby servo motors - obstacle scanner and water nozzle

An output component turns an electrical control signal into light, sound, motion, switching, or displayed information.

What it does here

It presents the circuit result or acts on the physical world.

Buy / compare this part

Advantages

  • Makes system state visible
  • Can be tested separately
  • Supports clear troubleshooting

Limitations

  • Loads may exceed controller current
  • Polarity or driver direction can matter
  • Inductive loads create voltage spikes

Handling

  • Use the documented driver stage
  • Check polarity and load current
  • Add flyback protection for inductive loads

Specifications to verify

  • Use the exact model, value, package, and rating listed for Two hobby servo motors - obstacle scanner and water nozzle; similar-looking parts are not always interchangeable.
  • Confirm voltage, current, polarity, interface, driver requirements, and duty cycle.
P12 V DC water pumpPART1
What's this?Image, role, pros, cons, handling & specifications
230V AC water pumpPART LEARNING VIEW

12 V DC water pump

An output component turns an electrical control signal into light, sound, motion, switching, or displayed information.

What it does here

It presents the circuit result or acts on the physical world.

Buy / compare this part

Advantages

  • Makes system state visible
  • Can be tested separately
  • Supports clear troubleshooting

Limitations

  • Loads may exceed controller current
  • Polarity or driver direction can matter
  • Inductive loads create voltage spikes

Handling

  • Use the documented driver stage
  • Check polarity and load current
  • Add flyback protection for inductive loads

Specifications to verify

  • Use the exact model, value, package, and rating listed for 12 V DC water pump; similar-looking parts are not always interchangeable.
  • Confirm voltage, current, polarity, interface, driver requirements, and duty cycle.
PLogic-level N-channel MOSFET or rated relay pump driverPART1
What's this?Image, role, pros, cons, handling & specifications
Arduino fire fighting robot components including Arduino Uno, HC-SR04 sensor, two SG90 servos, L293D driver, flame sensor, geared motors, water pump and chassisPART LEARNING VIEW

Logic-level N-channel MOSFET or rated relay pump driver

An output component turns an electrical control signal into light, sound, motion, switching, or displayed information.

What it does here

It presents the circuit result or acts on the physical world.

Buy / compare this part

Advantages

  • Makes system state visible
  • Can be tested separately
  • Supports clear troubleshooting

Limitations

  • Loads may exceed controller current
  • Polarity or driver direction can matter
  • Inductive loads create voltage spikes

Handling

  • Use the documented driver stage
  • Check polarity and load current
  • Add flyback protection for inductive loads

Specifications to verify

  • Use the exact model, value, package, and rating listed for Logic-level N-channel MOSFET or rated relay pump driver; similar-looking parts are not always interchangeable.
  • Confirm voltage, current, polarity, interface, driver requirements, and duty cycle.
P1N4007 flyback diode for the pumpPART1
What's this?Image, role, pros, cons, handling & specifications
1N4007 rectifier diodePART LEARNING VIEW

1N4007 flyback diode for the pump

An output component turns an electrical control signal into light, sound, motion, switching, or displayed information.

What it does here

It presents the circuit result or acts on the physical world.

Buy / compare this part

Advantages

  • Makes system state visible
  • Can be tested separately
  • Supports clear troubleshooting

Limitations

  • Loads may exceed controller current
  • Polarity or driver direction can matter
  • Inductive loads create voltage spikes

Handling

  • Use the documented driver stage
  • Check polarity and load current
  • Add flyback protection for inductive loads

Specifications to verify

  • Use the exact model, value, package, and rating listed for 1N4007 flyback diode for the pump; similar-looking parts are not always interchangeable.
  • Confirm voltage, current, polarity, interface, driver requirements, and duty cycle.
PBuzzerPART1
What's this?Image, role, pros, cons, handling & specifications
Arduino fire fighting robot components including Arduino Uno, HC-SR04 sensor, two SG90 servos, L293D driver, flame sensor, geared motors, water pump and chassisPART LEARNING VIEW

Buzzer

An output component turns an electrical control signal into light, sound, motion, switching, or displayed information.

What it does here

It presents the circuit result or acts on the physical world.

Buy / compare this part

Advantages

  • Makes system state visible
  • Can be tested separately
  • Supports clear troubleshooting

Limitations

  • Loads may exceed controller current
  • Polarity or driver direction can matter
  • Inductive loads create voltage spikes

Handling

  • Use the documented driver stage
  • Check polarity and load current
  • Add flyback protection for inductive loads

Specifications to verify

  • Use the exact model, value, package, and rating listed for Buzzer; similar-looking parts are not always interchangeable.
  • Confirm voltage, current, polarity, interface, driver requirements, and duty cycle.
PRobot chassis, wheels and casterPART1
What's this?Image, role, pros, cons, handling & specifications
Arduino fire fighting robot components including Arduino Uno, HC-SR04 sensor, two SG90 servos, L293D driver, flame sensor, geared motors, water pump and chassisPART LEARNING VIEW

Robot chassis, wheels and caster

A named project component whose exact role is defined by the source circuit and build guide.

What it does here

It performs a documented electrical, control, interface, or construction function in this project.

Buy / compare this part

Advantages

  • Selected for this project
  • Can be checked independently
  • Supports modular troubleshooting

Limitations

  • Substitutes may differ
  • Generic names can hide variants
  • Pinouts and ratings vary

Handling

  • Compare the received part with the source
  • Keep it labelled
  • Do not force connectors or adjusters

Specifications to verify

  • Use the exact model, value, package, and rating listed for Robot chassis, wheels and caster; similar-looking parts are not always interchangeable.
  • Confirm dimensions, ratings, connection method, polarity, and environmental limits.
PWater tank, insulated tubing and spray nozzlePART1
What's this?Image, role, pros, cons, handling & specifications
Arduino fire fighting robot components including Arduino Uno, HC-SR04 sensor, two SG90 servos, L293D driver, flame sensor, geared motors, water pump and chassisPART LEARNING VIEW

Water tank, insulated tubing and spray nozzle

A named project component whose exact role is defined by the source circuit and build guide.

What it does here

It performs a documented electrical, control, interface, or construction function in this project.

Buy / compare this part

Advantages

  • Selected for this project
  • Can be checked independently
  • Supports modular troubleshooting

Limitations

  • Substitutes may differ
  • Generic names can hide variants
  • Pinouts and ratings vary

Handling

  • Compare the received part with the source
  • Keep it labelled
  • Do not force connectors or adjusters

Specifications to verify

  • Use the exact model, value, package, and rating listed for Water tank, insulated tubing and spray nozzle; similar-looking parts are not always interchangeable.
  • Confirm dimensions, ratings, connection method, polarity, and environmental limits.
PSeparate regulated 5-6 V servo supplyPART1
What's this?Image, role, pros, cons, handling & specifications
Arduino fire fighting robot components including Arduino Uno, HC-SR04 sensor, two SG90 servos, L293D driver, flame sensor, geared motors, water pump and chassisPART LEARNING VIEW

Separate regulated 5-6 V servo supply

An output component turns an electrical control signal into light, sound, motion, switching, or displayed information.

What it does here

It presents the circuit result or acts on the physical world.

Buy / compare this part

Advantages

  • Makes system state visible
  • Can be tested separately
  • Supports clear troubleshooting

Limitations

  • Loads may exceed controller current
  • Polarity or driver direction can matter
  • Inductive loads create voltage spikes

Handling

  • Use the documented driver stage
  • Check polarity and load current
  • Add flyback protection for inductive loads

Specifications to verify

  • Use the exact model, value, package, and rating listed for Separate regulated 5-6 V servo supply; similar-looking parts are not always interchangeable.
  • Confirm voltage, current, polarity, interface, driver requirements, and duty cycle.
P12 V motor and pump supplyPART1
What's this?Image, role, pros, cons, handling & specifications
Arduino fire fighting robot components including Arduino Uno, HC-SR04 sensor, two SG90 servos, L293D driver, flame sensor, geared motors, water pump and chassisPART LEARNING VIEW

12 V motor and pump supply

An output component turns an electrical control signal into light, sound, motion, switching, or displayed information.

What it does here

It presents the circuit result or acts on the physical world.

Buy / compare this part

Advantages

  • Makes system state visible
  • Can be tested separately
  • Supports clear troubleshooting

Limitations

  • Loads may exceed controller current
  • Polarity or driver direction can matter
  • Inductive loads create voltage spikes

Handling

  • Use the documented driver stage
  • Check polarity and load current
  • Add flyback protection for inductive loads

Specifications to verify

  • Use the exact model, value, package, and rating listed for 12 V motor and pump supply; similar-looking parts are not always interchangeable.
  • Confirm voltage, current, polarity, interface, driver requirements, and duty cycle.
M5 V regulated Arduino supplyMODULE1
What's this?Image, role, pros, cons, handling & specifications
Arduino fire fighting robot components including Arduino Uno, HC-SR04 sensor, two SG90 servos, L293D driver, flame sensor, geared motors, water pump and chassisMODULE LEARNING VIEW

5 V regulated Arduino supply

A programmable controller that reads inputs, makes decisions, and drives the project's outputs.

What it does here

It is the control centre and must use the documented board, pin map, supply, and logic level.

Buy / compare this part

Advantages

  • Reprogrammable and reusable
  • Large learning ecosystem
  • Complex behaviour remains changeable

Limitations

  • GPIO voltage and current are limited
  • Some pins affect boot or communication
  • Loads normally need a driver

Handling

  • Disconnect power before rewiring
  • Avoid static discharge
  • Never power motors, relays, or pumps directly from GPIO

Specifications to verify

  • Use the exact model, value, package, and rating listed for 5 V regulated Arduino supply; similar-looking parts are not always interchangeable.
  • Confirm operating voltage, logic level, pinout, memory, USB interface, and maximum GPIO current.
BJumper wires, connectors and prototype PCBBUILD1
What's this?Image, role, pros, cons, handling & specifications
Arduino fire fighting robot components including Arduino Uno, HC-SR04 sensor, two SG90 servos, L293D driver, flame sensor, geared motors, water pump and chassisBUILD LEARNING VIEW

Jumper wires, connectors and prototype PCB

A named project component whose exact role is defined by the source circuit and build guide.

What it does here

It performs a documented electrical, control, interface, or construction function in this project.

Buy / compare this part

Advantages

  • Selected for this project
  • Can be checked independently
  • Supports modular troubleshooting

Limitations

  • Substitutes may differ
  • Generic names can hide variants
  • Pinouts and ratings vary

Handling

  • Compare the received part with the source
  • Keep it labelled
  • Do not force connectors or adjusters

Specifications to verify

  • Use the exact model, value, package, and rating listed for Jumper wires, connectors and prototype PCB; similar-looking parts are not always interchangeable.
  • Confirm dimensions, ratings, connection method, polarity, and environmental limits.
PCommon-ground wiring between all suppliesPART1
What's this?Image, role, pros, cons, handling & specifications
Arduino fire fighting robot components including Arduino Uno, HC-SR04 sensor, two SG90 servos, L293D driver, flame sensor, geared motors, water pump and chassisPART LEARNING VIEW

Common-ground wiring between all supplies

A named project component whose exact role is defined by the source circuit and build guide.

What it does here

It performs a documented electrical, control, interface, or construction function in this project.

Buy / compare this part

Advantages

  • Selected for this project
  • Can be checked independently
  • Supports modular troubleshooting

Limitations

  • Substitutes may differ
  • Generic names can hide variants
  • Pinouts and ratings vary

Handling

  • Compare the received part with the source
  • Keep it labelled
  • Do not force connectors or adjusters

Specifications to verify

  • Use the exact model, value, package, and rating listed for Common-ground wiring between all supplies; similar-looking parts are not always interchangeable.
  • Confirm dimensions, ratings, connection method, polarity, and environmental limits.
Ready to continue?
STEP 4 / 6 · Source code

Prepare, upload, and verify the program.

Follow the same software sequence every time: verify connections, prepare the toolchain, compile, and upload.

01

How to connect

  1. Match every controller label to the circuit view and source pin map.
  2. Join grounds before signal wires when separate low-voltage supplies are used.
  3. Keep motors, relays, pumps, and other loads on a suitable driver and external supply.

Common mistakes

Reversed VCC/GND, board-label versus GPIO-number confusion, missing common ground, and charge-only USB cables.

Troubleshoot

Disconnect loads, continuity-test one path at a time, then test with a current limit.

02

Software preparation

  1. Install the current Arduino IDE or the software named in the guide.
  2. Install the correct board package and required libraries.
  3. Select the exact board, processor, and serial port.
  4. Compile once before connecting external loads.
03

How to upload code

  1. Connect the board with a data-capable USB cable.
  2. Open the documented sketch and confirm configuration values.
  3. Compile, fix the first reported error, and upload.
  4. Test with external loads disconnected first.

Common mistakes

Wrong port, missing library, incorrect board selection, boot pins held in the wrong state, or a busy serial port.

Download source code
Software Specifications

1. Arduino Compiler 2. Programming Language: C

Reference Sketch Wiring

This Circuit Atlas reference sketch uses the following Arduino Uno pin map because the source block diagram does not assign pins.

L293D left motor: IN1=D2, IN2=D3, ENA=D5 (PWM) L293D right motor: IN3=D4, IN4=D7, ENB=D6 (PWM) HC-SR04: TRIG=D8, ECHO=D9 Obstacle-scanning servo signal: D10 Water-nozzle servo signal: D11 Pump MOSFET or relay input: D12 Buzzer: D13 Analog flame sensor output: A0

Power the servos, motors, and pump from suitable external supplies. Never drive the pump from an Arduino pin. Join the external supply grounds to Arduino GND, add a flyback diode across a DC pump when using a MOSFET, and keep all water paths physically isolated from the electronics.

Library and Upload Settings

Board: Arduino Uno Processor: ATmega328P Required library: Servo by Arduino Serial monitor: 115200 baud

The Servo library disables PWM on Uno pins 9 and 10. The reference wiring therefore uses PWM pins 5 and 6 for the L293D motor-enable inputs. Pins 9 and 10 are used only for the ultrasonic echo and servo signal.

Circuit Atlas Reference Arduino Sketch
/*
  Circuit Atlas reference sketch
  Project 301 - Arduino Based Autonomous Fire Fighting Robot

  Target board: Arduino Uno R3
  Required library: Servo (installable from Arduino Library Manager)

  IMPORTANT ELECTRICAL SAFETY
  - Never power the water pump, drive motors, or servos from an Arduino I/O pin.
  - Use an L293D (or equivalent driver) for the two drive motors.
  - Use a logic-level MOSFET or a rated relay module for the 12 V pump.
  - Fit a flyback diode across the pump when using a discrete MOSFET driver.
  - Use suitable external supplies and connect every supply ground together.
  - Keep water, tubing, and leaks physically separated from all electronics.

  The source document contains a block diagram but no pin assignments. The
  pin map below is a tested-for-conflicts reference layout; update it to match
  your build before applying motor or pump power.
*/

#include <Servo.h>

// L293D motor driver. Servo disables PWM on Uno pins 9 and 10, so the motor
// enable pins deliberately use PWM pins 5 and 6.
constexpr uint8_t LEFT_MOTOR_IN1 = 2;
constexpr uint8_t LEFT_MOTOR_IN2 = 3;
constexpr uint8_t RIGHT_MOTOR_IN1 = 4;
constexpr uint8_t RIGHT_MOTOR_IN2 = 7;
constexpr uint8_t LEFT_MOTOR_ENABLE = 5;
constexpr uint8_t RIGHT_MOTOR_ENABLE = 6;

// HC-SR04 obstacle sensor, mounted on the scan servo.
constexpr uint8_t ULTRASONIC_TRIG = 8;
constexpr uint8_t ULTRASONIC_ECHO = 9;
constexpr uint8_t SCAN_SERVO_PIN = 10;

// Fire suppression hardware.
constexpr uint8_t NOZZLE_SERVO_PIN = 11;
constexpr uint8_t PUMP_DRIVER_PIN = 12;
constexpr uint8_t BUZZER_PIN = 13;
constexpr uint8_t FLAME_SENSOR_PIN = A0;

// Adjust these values during the dry bench test.
constexpr bool FLAME_READING_DECREASES_NEAR_FIRE = true;
constexpr int FLAME_THRESHOLD = 430;       // Uno ADC range: 0 to 1023.
constexpr int OBSTACLE_DISTANCE_CM = 25;
constexpr uint8_t DRIVE_SPEED = 175;       // PWM range: 0 to 255.
constexpr uint8_t TURN_SPEED = 165;
constexpr unsigned long MAX_SPRAY_TIME_MS = 8000;
constexpr unsigned long FIRE_CLEAR_CONFIRM_MS = 1200;

constexpr int SCAN_CENTER_DEG = 90;
constexpr int SCAN_LEFT_DEG = 150;
constexpr int SCAN_RIGHT_DEG = 30;
constexpr int NOZZLE_MIN_DEG = 55;
constexpr int NOZZLE_MAX_DEG = 125;
constexpr int NOZZLE_CENTER_DEG = 90;

Servo scanServo;
Servo nozzleServo;

enum class RobotMode : uint8_t {
  Patrol,
  Extinguishing
};

RobotMode mode = RobotMode::Patrol;
unsigned long lastDiagnosticMs = 0;

void setMotor(uint8_t in1, uint8_t in2, uint8_t enablePin, int speedValue) {
  const int limitedSpeed = constrain(abs(speedValue), 0, 255);

  if (speedValue > 0) {
    digitalWrite(in1, HIGH);
    digitalWrite(in2, LOW);
  } else if (speedValue < 0) {
    digitalWrite(in1, LOW);
    digitalWrite(in2, HIGH);
  } else {
    digitalWrite(in1, LOW);
    digitalWrite(in2, LOW);
  }

  analogWrite(enablePin, limitedSpeed);
}

void drive(int leftSpeed, int rightSpeed) {
  setMotor(LEFT_MOTOR_IN1, LEFT_MOTOR_IN2, LEFT_MOTOR_ENABLE, leftSpeed);
  setMotor(RIGHT_MOTOR_IN1, RIGHT_MOTOR_IN2, RIGHT_MOTOR_ENABLE, rightSpeed);
}

void stopDrive() {
  drive(0, 0);
}

int readFlameSensor() {
  long total = 0;
  constexpr uint8_t sampleCount = 8;

  for (uint8_t sample = 0; sample < sampleCount; ++sample) {
    total += analogRead(FLAME_SENSOR_PIN);
    delayMicroseconds(300);
  }

  return static_cast<int>(total / sampleCount);
}

bool flameDetected(int reading) {
  return FLAME_READING_DECREASES_NEAR_FIRE
    ? reading <= FLAME_THRESHOLD
    : reading >= FLAME_THRESHOLD;
}

long readDistanceCm() {
  digitalWrite(ULTRASONIC_TRIG, LOW);
  delayMicroseconds(3);
  digitalWrite(ULTRASONIC_TRIG, HIGH);
  delayMicroseconds(10);
  digitalWrite(ULTRASONIC_TRIG, LOW);

  // A 30 ms timeout is roughly five metres and prevents a missing echo from
  // blocking the robot indefinitely.
  const unsigned long echoTimeUs = pulseIn(ULTRASONIC_ECHO, HIGH, 30000UL);
  if (echoTimeUs == 0) {
    return 400;
  }

  return static_cast<long>((echoTimeUs * 0.0343F) / 2.0F);
}

long lookAt(int angle) {
  scanServo.write(constrain(angle, 0, 180));
  delay(350);
  return readDistanceCm();
}

void avoidObstacle() {
  stopDrive();
  delay(120);

  const long leftDistance = lookAt(SCAN_LEFT_DEG);
  const long rightDistance = lookAt(SCAN_RIGHT_DEG);
  scanServo.write(SCAN_CENTER_DEG);
  delay(180);

  if (leftDistance < OBSTACLE_DISTANCE_CM && rightDistance < OBSTACLE_DISTANCE_CM) {
    drive(-TURN_SPEED, -TURN_SPEED);
    delay(420);
  }

  if (leftDistance >= rightDistance) {
    drive(-TURN_SPEED, TURN_SPEED);
  } else {
    drive(TURN_SPEED, -TURN_SPEED);
  }
  delay(430);
  stopDrive();
}

void patrol() {
  const long frontDistance = readDistanceCm();

  if (frontDistance <= OBSTACLE_DISTANCE_CM) {
    avoidObstacle();
  } else {
    drive(DRIVE_SPEED, DRIVE_SPEED);
  }
}

void setPump(bool enabled) {
  digitalWrite(PUMP_DRIVER_PIN, enabled ? HIGH : LOW);
}

void extinguishFire() {
  stopDrive();
  tone(BUZZER_PIN, 2400);
  setPump(true);

  const unsigned long sprayStartedMs = millis();
  unsigned long clearStartedMs = 0;
  int nozzleAngle = NOZZLE_MIN_DEG;
  int sweepStep = 3;

  while (millis() - sprayStartedMs < MAX_SPRAY_TIME_MS) {
    nozzleServo.write(nozzleAngle);

    nozzleAngle += sweepStep;
    if (nozzleAngle >= NOZZLE_MAX_DEG || nozzleAngle <= NOZZLE_MIN_DEG) {
      sweepStep = -sweepStep;
      nozzleAngle = constrain(nozzleAngle, NOZZLE_MIN_DEG, NOZZLE_MAX_DEG);
    }

    const int flameReading = readFlameSensor();
    if (!flameDetected(flameReading)) {
      if (clearStartedMs == 0) {
        clearStartedMs = millis();
      }
      if (millis() - clearStartedMs >= FIRE_CLEAR_CONFIRM_MS) {
        break;
      }
    } else {
      clearStartedMs = 0;
    }

    delay(35);
  }

  setPump(false);
  noTone(BUZZER_PIN);
  nozzleServo.write(NOZZLE_CENTER_DEG);
  delay(350);
  mode = RobotMode::Patrol;
}

void printDiagnostics(int flameReading) {
  if (millis() - lastDiagnosticMs < 500) {
    return;
  }

  lastDiagnosticMs = millis();
  Serial.print(F("Flame ADC: "));
  Serial.print(flameReading);
  Serial.print(F(" | Fire: "));
  Serial.print(flameDetected(flameReading) ? F("YES") : F("no"));
  Serial.print(F(" | Distance cm: "));
  Serial.println(readDistanceCm());
}

void setup() {
  pinMode(LEFT_MOTOR_IN1, OUTPUT);
  pinMode(LEFT_MOTOR_IN2, OUTPUT);
  pinMode(RIGHT_MOTOR_IN1, OUTPUT);
  pinMode(RIGHT_MOTOR_IN2, OUTPUT);
  pinMode(LEFT_MOTOR_ENABLE, OUTPUT);
  pinMode(RIGHT_MOTOR_ENABLE, OUTPUT);
  pinMode(ULTRASONIC_TRIG, OUTPUT);
  pinMode(ULTRASONIC_ECHO, INPUT);
  pinMode(PUMP_DRIVER_PIN, OUTPUT);
  pinMode(BUZZER_PIN, OUTPUT);
  pinMode(FLAME_SENSOR_PIN, INPUT);

  // Establish a safe output state before attaching actuators.
  stopDrive();
  setPump(false);
  noTone(BUZZER_PIN);

  scanServo.attach(SCAN_SERVO_PIN);
  nozzleServo.attach(NOZZLE_SERVO_PIN);
  scanServo.write(SCAN_CENTER_DEG);
  nozzleServo.write(NOZZLE_CENTER_DEG);

  Serial.begin(115200);
  Serial.println(F("Circuit Atlas fire-fighting robot starting"));
  delay(800);
}

void loop() {
  const int flameReading = readFlameSensor();
  printDiagnostics(flameReading);

  if (flameDetected(flameReading)) {
    mode = RobotMode::Extinguishing;
  }

  if (mode == RobotMode::Extinguishing) {
    extinguishFire();
  } else {
    patrol();
  }
}
Ready to continue?
STEP 5 / 6 · Build

Assemble, deploy, test, and troubleshoot.

Use the complete source notes in build order, then pass the final checks before calling the project finished.

ASSEMBLY

Build in functional stages

  • Power and regulation
  • Controller or processing stage
  • Inputs and sensors
  • Outputs and loads
  • Enclosure and strain relief
TEST

Power up safely

  • Inspect unpowered continuity first
  • Apply the lowest safe current limit
  • Measure supply rails before signals
  • Add one load at a time
  • Record expected and actual results
TROUBLESHOOT

Work from simple to complex

  • Confirm power, ground, polarity, and orientation
  • Compare each pin with the source
  • Test inputs separately from outputs
  • Replace only one variable at a time
  • Power off before every correction
PROJECT-SPECIFIC BUILD NOTES

Follow the documented instructions.

These notes come from this project's source and remain in their original order.

01

Project overview

Project build note

30 1. Arduino Based Autonomous Fire Fighting Robot Firefighters can independently detect fires with this sophisticated firefighting robotic system. Fire fighters face an increasing risk of death as technology leads to an automated system and self-traveling vehicles. If a fire is not controlled, it will spread rapidly. Even an explosion is possible in the event of a gas leak. The system delivers by overcoming this issue, safeguarding the lives of our heroes. An Arduino Uno is used to power this firefighting robotic system which is comprised of an ultrasonic sensor positioned on a servo motor for obstacle detection and free route navigation. Despite its small size, it has the capability to detect and extinguish fires. It also has water tank and spray mechanism for extinguishing flames. Servo motor is used to cover maximum area with water spraying nozzle. The 12V pump uses an electric motor to pump water from the main tank to the water nozzle. Because of its constant current consumption, this pump needs driver circuit.

02

Hardware Specifications

Project build note

Arduino Uno Ultrasonic Sensor Fire Fighter Robot Body Fire Sensor Buzzer LCD Display Resistors Capacitors

Transistors Cables and Connectors Diodes PCB and Breadboards LED Transformer/Adapter Push Buttons Switch IC IC Sockets

Firefighting robotic systems are designed with specific tasks in mind. The primary aspects of fire control and suppression are analyzing and locating fires as well as conducting search and rescue operations. Robotic systems for controlling fire, such as automatically activating fire alarms and sprinklers, can quickly extinguish anything in a heavily populated or hazardous area. These systems are usually simpler and primarily rely on UV or infrared sensors. Since they are fixed, they don't typically change over time.

03

Calibration and First Test

Project build note

1. Raise the wheels off the bench and disconnect the pump supply before the first upload. 2. Open the Serial Monitor at 115200 baud and record the flame sensor reading with no flame, then with a small supervised test flame at a safe distance. Adjust FLAME_THRESHOLD and FLAME_READING_DECREASES_NEAR_FIRE in the sketch. 3. Confirm that both wheels move forward. If one runs backward, swap that motor's two output wires or reverse its IN pin logic. 4. Place a flat object in front of the HC-SR04 and confirm that the robot stops and scans both directions at approximately 25 cm. 5. Test the nozzle servo without water. Then test the pump driver separately with a fused supply and verify that the Arduino output switches only the driver input. 6. Perform any live-flame test outdoors or in a controlled fire-safe area with an extinguisher and qualified supervision. This educational robot is not certified life-safety equipment.

Ready to continue?
PROJECT ACHIEVED

You built Arduino Based Autonomous Fire Fighting Robot.

You followed the full workflow from understanding the mission to testing the finished project. That is a real engineering achievement - well done.

Robot Snake based on Arduino controlled by Android project thumbnail featuring Arduino mega, IR Sensor, Servo Motors
NEXT ARDUINO ADVENTURE

Robot Snake based on Arduino controlled by Android

Ready to reuse what you learned in another project from the same track?

Start this project
Browse all 500 projects