Skip to main content

Case 28 The Obstacle Avoidance Line Following Car

Introduction

In this project we will use the Nezha Inventor's Kit V2 to build a smart cart that can not only patrol along a black line, but also avoid obstacles while doing so. We will learn how the dual line following sensors and ultrasonic sound sensors work and apply them to the creation of the cart.

Teaching Objetives

  • Understanding the working principle of the dual line-following sensor
  • Understand how ultrasonic sound sensors work
  • Learn to use the Nezha Inventor's Kit V2 for mechanical construction
  • Learn to install and connect the dual patrol sensor and the ultrasonic sound sensor
  • Learn to program and control the vehicle for patrol and obstacle avoidance

Teaching Preparation

Nezha Inventor's Kit V2

Teaching Process

Introduce

Introduce students to the background and objectives of making an obstacle avoidance patrol car to stimulate their interest and curiosity.

Now, let's think together: how interesting and practical a robot would it be if we had a small car that could not only automatically follow the black line, but also intelligently avoid obstacles? This little car would be able to follow the black line while detecting obstacles in front of it via ultrasonic sound sensors and taking the appropriate action to avoid them.

In this course we will take a closer look at how the dual line following sensors and ultrasonic sound sensors work and apply them to the construction of a line following car. We will learn how to build the mechanics of the cart and mount the dual line following sensors and ultrasonic sound sensors on the cart. By writing a program, we will realise that the trolley can intelligently avoid obstacles while patrolling the route.

Exploration

Discuss in small groups and get students thinking about how to build an obstacle-avoidance line following car using block materials.

  • How does the two-way line following sensor work? How does it identify black lines?
  • How does the ultrasonic sound sensor work? How does it detect an obstacle in front of it?
  • How do you connect and program the dual line following sensor and ultrasonic sound sensor to the Nezha Inventor's Kit V2?
  • How does it intelligently avoid obstacles based on the signals from the ultrasonic sound sensors while the trolley is patrolling the line?

Practice

Work in groups to create an obstacle-avoidance patrol car from building blocks according to your own design.

Build an obstacle-avoidance line following car from blocks according to your own design.

Examples

Assembly Steps

Completed

Hardware Connection

Connect the line following sensor to the J1, the ultrasonic sound sensor to the J2 and the motors to the M1 and M2 connectors of the Nezha expansion board.

Programming

Go to makecode

Create new projects

Click extensions

Search with PlanetX to download the package.

Search with nezha to download the package.

Code

Link: https://makecode.microbit.org/_V4mTg3PiwPjy

You may download it directly below:

Demonstration

Present in groups and compare the results and effectiveness of each group.

Result

The car moves along the black line and stops automatically when it encounters an obstacle.

Reflection

Share in groups so that students in each group can share their production process and insights, summarise the problems and solutions they encountered, and evaluate their strengths and weaknesses.