Picar-X Lesson 6 Overtake or Keep the Distance?

Basic Teaching Information

Suitable School Age

9-12 years old


90 minutes



Teaching Objectives

1. Get to know the ultrasonic obstacle avoidance technology in automatic drive.

2. Learn the definition of ultrasonic wave.

3. Understand the working principle and application scenarios of ultrasonic sensor.

4. Review variables.

5. Learn about the ranging function of ultrasonic sensor and the use of number blocks, sound effect blocks and On/Off switch blocks.

Important and Difficult Points of Teaching

Teaching Key Points

Learn the working principle of ultrasonic sensor. Use variables to store the ranging data of ultrasonic sensor.

Teaching Difficult Points

Learn how to make PiCar overtake the car in front of it and then back to its original lane and keep some distance away from the car behind.

Teaching Form

Give a lecture, cooperative group learning.



Teaching Grouping and Teaching Aid

Teaching Group

Work in groups of one person.

Teaching Aid

PiCar (each student has one), tablet computer (each student has one)

pen, and programming growth manual, paper cube and adhesive tape.

Teaching Procedure

Teaching Stage

Teaching Content


1. Lead in

Without a driver, how can a self-driving car know there is an obstacle in front of it? The tool that help it avoid obstacles is called ultrasonic sensors.

Know ultrasonic wave and explain the working principle of ultrasonic wave. 

List the scenarios in your life where ultrasonic sensors are used.

15 minutes

2. Objective

Students give PiCar an overtaking switch. When the switch is on, PiCar gets around the obstacle ahead; otherwise, PiCar doesn't.

Students use blocks and paper cubes to make an obstacle, and use tape to draw a lane.

5 minutes

3. Program Test

Just as random numbers need to be stored in variables, so does the distance measured by ultrasonic sensors in this lesson.

Explain the usage of ultrasonic block, sound effect, number block.

Task 1: Make PiCar print the real-time measured distance on the debug monitor and emit an alarm when the distance between PiCar and the obstacle ahead is < 20cm.

Task 2: PiCar drives at a 10% speed. 20CM ahead is another car. PiCar overtakes the car in front of it through the left lane and then backs to its original lane.

30-45 minutes

4. Read the program flow, complete tasks and optimize them.

Read the flow chart of the program, edit the final task program independently, and complete the task.

Guide the students to add various expansions according to their own ideas on the basis of completing the task (teachers can teach students according to their aptitude in this process, and the learning difficulty of students with better ability can be increased).

Task 3: Let PiCar drive at a 10% speed. Students give PiCar an overtaking switch. When the switch is on, PiCar gets around the obstacle ahead; otherwise, PiCar doesn't.

In this process, the teacher helps the children to be creative and make the game more fun.

15-30 minutes

5. Summary and Reflection

Summary:1. What does a self-driving car need to avoid obstacles?

2. How does an ultrasonic sensor work?

3. What does a variable do?


What did we ask PiCar to accomplish today? What difficulties did we encounter and what did we learn from this process?

10 minutes

6. Homework

Use an ultrasonic sensor to design a fantastic usage scenario and think whether PiCar can do it. If so, think about how to program; If not, ask teachers for help.