Firefighting Robot | Maqueen Plus V2 Getting started Tutorial 13

1 1523 Easy

Firefighting is a highly dangerous occupation. When an emergency response call comes, firefighters must get themselves dressed in the appropriate gear and onto the emergency vehicles quickly to arrive at the fire scene, and then extinguish the fire. Firefighters are risking their lives to defend our cities and country. So everybody, can we use what we learned to help reduce the risk? How about a firefighting robot? Let's make a firefighting robot with Maqueen Plus V2, and let it complete three actions: Call out, Firefighting, and Mission done. A flame sensor and servo will be used in this project. Maqueen Plus V2 has 8 GPIO ports and 3 servo ports for connecting Gravity modules and servos. Everything is ready, let's start!
 

Goal

1. Learn how to drive a servo

2. Learn how to use a flame sensor

3. Learn how to use OLED display

Electronic Component

Command Learning

Hands-on Practic

Step 1 Create a New Project

1. Input https://makecode.microbit.org/ into your browser to enter the MakeCode editor.

2. Click "new project" to enter the MakeCode programming interface.

3. Add the Maqueen Plus V2 library: https://github.com/DFRobot/pxt-DFRobot_MaqueenPlus_v20

4. Click "Setting"->"Extensions", input the following address and click the result OLEDV1: https://github.com/DFRobot/pxt-OLED

Step 2 Programming

1. Generally, there are three parts to the firefighting process.

(1) Received the emergency call, and go to the fire scene;

(2) Arrived at the scene, and extinguish the fire.

(3) Mission completed.

So, we will create three functions: "Call out", "Firefighting", and "Mission done". Take the first one as an example.

Create another two functions Firefighting and Mission done in the same way above.

2. Then do condition judgment as the flowchart shown below:

3. Initialize the Maqueen Plus V2 and OLED, and set the servo angle when the program starts.

4. Create a variable "i" to store the analog value read from the flame sensor.


 

5. Display the analog value of the flame sensor on the first line of the OLED screen.

6. Call the related functions according to the program flowchart.

When the analog value detected by the flame sensor is between 10-100, it means that there is a certain distance between the firefighting robot and the fire scene, and the robot has to go forward to the scene; if the value is larger than 100, the robot has arrived at the fire scene, and starts to extinguish the fire; when it is less than 10, the firefighting mission is done.


 

7. The realization of the "Call out" function: when the firefighting robot drives to the fire scene, the two LEDs on the left and right will flash red alternatively, with the siren blaring (use the sound "dadadum" to simulate the siren).

8. The realization of the function "Firefighting": when the firefighting robot arrived at the scene, turn on its fire hose to put out the fire (change the angle of the servo to simulate this process).

9. The function "Mission done": turn off the fire hose, LEDs, and siren.

10. The complete program is shown below.

11. Name your project "Firefighting robot", and download it into Maqueen Plus V2.

Step 3 Effect Display

Turn on the power switch when completed all the steps above. Then the analog value from the flame sensor will be constantly displayed on the OLED screen. When the value is in 10-100, the firefighting robot moves forward at the speed of 100 with its light flashing and siren blaring; when it is more than 100, the robot car stops, and its servo rotates 180 degrees; when less than 10, the servo back to 90 degrees, stop playing sound and turn off the RGB LEDs.

Note: we can use a lighter to imitate the fire scene. Although the flame sensor can detect fire, it is not fireproof. Please make sure the sensor always keeps a certain distance from the fire. This project involves dangerous action, please complete this chapter with the assistance of guardians or teachers.

Think & Explore

We all know that smoking is not only harmful to our own health but effecting others. Therefore, smoking is forbidden in some public places. Can we make an "Anti-smoking robot" to monitor smoking in real-time?

Tip: add a gas sensor based on this project.

 

Click Buy micro:Maqueen Plus V2 (Ni MH Rechargeable Battery) - an Advanced STEM Education Robot for micro:bit - DFRobot

Click Buy micro:Maqueen Plus V2 (18650 Battery) - an Advanced STEM Education Robot for micro:bit - DFRobot

Engage in learning the previous Robot project :  Motion Sensing Robot

License
All Rights
Reserved
licensBg
1