Auto-braking Robot | Maqueen Plus V2 Getting started Tutorial 08

0 2575 Easy

The most frequent cause of vehicle accidents is the unexpected existence of barriers while driving. An automated braking system will assist and minimize such collisions, and ensure driver safety and comfort. Based on the ultrasonic measurement principle, the auto-braking system can detect the distance between the car and the obstacle, then the robot car will brake automatically when very near the obstacle, which could be helpful for new drivers. Now let's turn Maqueen Plus V2 into an auto-braking robot.

Goal

1. Learn how to use variables.

2. Learn how to embed a condition block inside another one.

Electronic Component

Command Learning

Hands-on Practice

Step 1 Create a New Project

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

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

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

Step 2 Programming

1. Create a variable and name it "distance".

2. In this project, we need to monitor the distance value the sensor detected in real-time, so we have to assign the value to the variable "distance".

3. When the robot car is near the obstacle (distance<50cm in the example), it keeps going and the buzzer keeps beeping to give an alarm. Once the distance between them is smaller than the preset value (distance<30cm in the example), the auto-braking robot stops.

4. The robot car stops if the condition "distance<30" is true and moves forwards if it's false.

5. The buzzer keeps beeping if the condition "distance<50" is true, otherwise, it stops making sound.

6. The complete program is shown below.


 

Step 3 Download Program

Step 4 Effect Display

After we completed all the above steps, put an obstacle in front of the Maqueen Plus V2 car, and turn on the power switch. When the detected distance is smaller than 50, the buzzer keeps beeping; distance<30, the car stop.

Think & Explore

We have turned Maqueen Plus V2 into an automated braking robot. The robot car stops when it is very near an obstacle, but can you let Maqueen Plus V2 bypass it? Make an obstacle avoidance car according to the flowchart below.

 

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 next Robot project:Line-tracking Robot

Engage in learning the previous Robot project :  Little Ranging Expert

 

License
All Rights
Reserved
licensBg
0