Despite numerous preventative measures taken against fires, these natural/man-made disasters do occur from time to time. During fires, we are forced to use unsafe human resources for rescue and firefighting. With advancements in technology, particularly in robotics, it is highly likely that robots will replace humans in firefighting. This would improve the efficiency of firefighters and prevent them from risking their lives. Today, we will use Arduino to build a firefighting robot that will automatically sense a fire and activate water pumps.
In this project, we'll learn how to build a simple robot using Arduino that can move towards a fire and pump water around it to extinguish it. This is a very simple robot that will teach us basic robotic concepts; once you understand the basics, you can build more complex robots. So let's get started...
Required materials:
Arduino UNO
Fire sensors or flame sensors (3 units)
Servo motor (SG90)
L293D Motor Drive Module
Miniature DC submersible pump
small breadboard
Robot chassis (any type) with motor (2) and wheels (2)
a small can
Connecting wire
Working principle of firefighting robots:
The main brain of this project is Arduino, but in order to detect fires, we use a fire sensor module (flame sensor) as shown below.
As you can see, these sensors have an infrared receiver (photodiode) used to detect fires. How is this possible? When a fire is burning, it emits a small amount of infrared light, which is received by the infrared receiver on the sensor module. Then, we use an operational amplifier to check the voltage change across the infrared receiver. Thus, if a fire is detected, the output pin (DO) will give 0V (LOW), and if there is no fire, the output pin will give 5V (HIGH).
Therefore, we placed three such sensors in three directions on the robot to sense which direction the fire was burning.
We detect the direction of the fire, and we can use the L293D module to drive a motor to move it near the fire. When we get close to the fire, we must extinguish it with water. We can carry water using a small container, which also contains a 5V pump. The entire container is placed on top of the servo motor so we can control the direction in which the water must be sprayed. Now let's continue with the connection.
Circuit diagram:
The complete circuit diagram of this firefighting robot is shown below.
You can connect to all the displayed connections to upload the program and check its operation, or you can fully assemble the robot and then continue connecting. Both connection methods are very simple, and you should be able to handle them correctly.
Depending on the robot chassis you're using, you might not be able to use the same type of container I'm using. In that case, get creative and set up your own pumping system. However, the code will remain the same. I used a small aluminum can (a cold drink can) to hold the pump, and then poured water into it. I then assembled the entire can onto top of a servo motor to control the direction of the water. This is what my robot looks like after assembly.
As you can see, I've used glue to secure the servo fins to the bottom of the container and used nuts and bolts to secure the servo motor to the chassis. We can simply place the container on top of the motor and then trigger the pump inside to pump water out through the pipes. The servo can then be used to rotate the entire container to control the direction of the water flow.
Programming Arduino:
Once you have the hardware ready, you can upload your Arduino code to perform certain operations. The complete program is shown at the end of this page. However, I'll explain some important details further here.
As is well known, fire sensors output a high level when a fire occurs and a low level when a fire is detected. Therefore, we must continue to check these sensors for fire. If there is no fire, we require the motor to remain stopped, keeping all pins high, as shown below.
if (digitalRead(Left_S) ==1 && digitalRead(Right_S)==1 && digitalRead(Forward_S) ==1) //If Fire not detected all sensors are zero
{
Do not move the robot.
digitalWrite(LM1.HIGH);
digitalWrite(LM2.HIGH);
digitalWrite(RM1.HIGH);
digitalWrite(RM2.HIGH);
}
Similarly, in the event of a fire, we can instruct the robot to move in that direction by rotating the corresponding motor. Once it reaches the fire, the left and right sensors will not detect the fire because it will be positioned upright in front of it. Now we use a variable named "fire" to execute a function to extinguish the fire.
else if (digitalRead(Forward_S) ==0) //If Fire is straight ahead
{
//Move the robot forward
digitalWrite(LM1.HIGH);
digitalWrite(LM2.LOW);
digitalWrite(RM1.HIGH);
digitalWrite(RM2.LOW);
fire = true)
}
Once the variable "fire" becomes true, the Arduino code for the fire robot will execute the `put_off_fire` function until the fire is extinguished. This is accomplished using the code below.
while (fire == true)
{
put_off_fire();
}
In `put_off_fire()`, we simply stop the robot by raising all the pins. Then, we turn on the pump to push water out of the container, while simultaneously using a servo motor to rotate the container and distribute the water evenly. This is accomplished using the code below.
void put_off_fire()
{
delay (500);
digitalWrite(LM1.HIGH);
digitalWrite(LM2.HIGH);
digitalWrite(RM1.HIGH);
digitalWrite(RM2.HIGH);
digitalWrite(pump, HIGH); delay(500);
for (pos = 50; pos <= 130; pos += 1) {
myservo.write(pos);
delay(10);
}
for (pos = 130; pos >= 50; pos -= 1) {
myservo.write(pos);
delay(10);
}
digitalWrite(pump,LOW);
myservo.write(90);
fire=false;
}
Firefighting robot operation:
It is recommended to check the robot's output step by step, rather than running it all at once the first time. You can build the robot onto the servo motors and check if it can successfully track the fire. Then you can check if the pumps and servo motors are working properly. Once everything is working as expected, you can run the following procedures and enjoy the full operation of the firefighting robot.
The robot's full operation can be seen in the video below. The maximum distance at which it can detect a fire depends on the size of the fire; for small fires, the distance is relatively small. You can also use the potentiometer on top of the module to control the robot's sensitivity. I powered the robot with a power bank, but you can use batteries, even 12V batteries.
/*------ Arduino Fire Fighting Robot Code----- */
#include
Servo myservo;
int pos = 0;
boolean fire = false;
/*-------defining Inputs------*/
#define Left_S 9 // left sensor
#define Right_S 10 // right sensor
#define Forward_S 8 //forward sensor
/*-------defining Outputs------*/
#define LM1 2 // left motor
#define LM2 3 // left motor
#define RM1 4 // right motor
#define RM2 5 // right motor
#define pump 6
void setup()
{
pinMode(Left_S, INPUT);
pinMode(Right_S, INPUT);
pinMode(Forward_S, INPUT);
pinMode(LM1.OUTPUT);
pinMode(LM2.OUTPUT);
pinMode(RM1.OUTPUT);
pinMode(RM2.OUTPUT);
pinMode(pump, OUTPUT);
myservo.attach(11);
myservo.write(90);
}
void put_off_fire()
{
delay (500);
digitalWrite(LM1.HIGH);
digitalWrite(LM2.HIGH);
digitalWrite(RM1.HIGH);
digitalWrite(RM2.HIGH);
digitalWrite(pump, HIGH); delay(500);
for (pos = 50; pos <= 130; pos += 1) {
myservo.write(pos);
delay(10);
}
for (pos = 130; pos >= 50; pos -= 1) {
myservo.write(pos);
delay(10);
}
digitalWrite(pump,LOW);
myservo.write(90);
fire=false;
}
void loop()
{
myservo.write(90); //Sweep_Servo();
if (digitalRead(Left_S) ==1 && digitalRead(Right_S)==1 && digitalRead(Forward_S) ==1) //If Fire not detected all sensors are zero
{
Do not move the robot.
digitalWrite(LM1.HIGH);
digitalWrite(LM2.HIGH);
digitalWrite(RM1.HIGH);
digitalWrite(RM2.HIGH);
}
else if (digitalRead(Forward_S) ==0) //If Fire is straight ahead
{
//Move the robot forward
digitalWrite(LM1.HIGH);
digitalWrite(LM2.LOW);
digitalWrite(RM1.HIGH);
digitalWrite(RM2.LOW);
fire = true)
}
else if (digitalRead(Left_S) ==0) //If Fire is to the left
{
//Move the robot left
digitalWrite(LM1.HIGH);
digitalWrite(LM2.LOW);
digitalWrite(RM1.HIGH);
digitalWrite(RM2.HIGH);
}
else if (digitalRead(Right_S) ==0) //If Fire is to the right
{
//Move the robot right
digitalWrite(LM1.HIGH);
digitalWrite(LM2.HIGH);
digitalWrite(RM1.HIGH);
digitalWrite(RM2.LOW);
}
delay(300); //Slow down the speed of robot
while (fire == true)
{
put_off_fire();
}
}