Skip to main content

Case 12: Comprehensive test of competition tasks

Case introduction

Make a task vehicle to complete four tasks on the sports field at one time.

Teaching Preparation

NameGraphics
Nezha Pro Sport Kit

Teaching objectives

Make a competition task car and complete all tasks

Be familiar with the comprehensive application of four-way patrol line sensors and servos

Course introduction

Welcome children to join our STEAM wonderful journey! In the previous courses, we learned about the knowledge points such as car patrol line and servo control. In this class, we need to integrate these knowledge points and complete all tasks on the competition map.

Learning and exploration

Linkage use of multiple servos

Use of four-way patrol line sensors

How to use four-way patrol line sensors to help the car adjust its driving route

Building steps

Car building steps

Ball Retrieval Machine Construction Steps

Simple goal building steps

Basketball stand construction steps

Hardware connection

Connect the three smart motors to the M1, M2, and M3 interfaces of the Nezha Pro expansion board respectively, and connect the four-way line patrol sensor to the IIC interface of the Nezha Pro expansion board.

Four-way line patrol sensor - learning mode

The four-way line patrol sensor can learn the map background and line patrol track (i.e. black track) by pressing the button on the sensor. Follow the steps below to complete the learning:

①Focus the four-way line patrol sensor probe on the map background area and press the learning button;

②At this time, the 1st to 4th probe indicator lights are lit in reverse order, and the two learning indicators flash alternately;

③When the line patrol probe fill light emits colorful light and flashes at a high frequency, the line patrol probe should be moved back and forth horizontally on the background map and the line patrol track;

④Keep moving back and forth until the line patrol probe fill light stops flashing, and the learning is completed.

Note: When using, the height of the line patrol probe from the ground should be between 8mm and 16mm.

After successful learning, the two learning indicators will go out. When the line patrol probe detects the line patrol track, the corresponding probe indicator light will light up. When learning fails, the hollow circle and solid circle LEDs flash quickly at the same time, and the fill light RGB light goes out.

For more information, please visit: Plant Series Four-way Line Patrol Sensor WIKI

Code Programming

Go to "makecode.microbit.org" and click New Project.

Enter a project name in the pop-up window and click Create.

Click Extension in the code drawer.

In the pop-up interface, enter nezha pro and click the search icon. Click it when the nezha pro software library is displayed. Load the PlanetX software library in the same way.

Sample Program

This program is relatively complex, please view it through the following shared program link.

Program link: https://makecode.microbit.org/_gif2bx60zehe

You can also download the program directly from the following webpage.

## Download the program

Use a USB cable to connect PC and micro:bit V2.

After the connection is successful, a drive letter named MICROBIT will be recognized on the computer.

Click in the lower left corner and select Connect Device.

Click

Click

In the pop-up window, select BBC micro:bit CMSIS-DAP, and then select Connect. At this point, our micro:bit has been successfully connected.

Click Download the program

Case Demonstration

Place the car in the upper left corner of the start area, close to the edge, and press the A button on the micro:bit to start the robot from the start area and complete all tasks

Note: Due to the error in the car construction, the success rate of this case is not 100%, and the program can be optimized to increase the success rate

Summary and sharing

Expand your knowledge