Introduction: Use distance sensors and four digit digital tubes to make distance measuring devices.
Advanced: Research on the performance of different sensor types. Length measuring tool -2-8cm infrared ranging, 15cm external distance sensor
Advanced: Control the movement of the car by a specified length based on the measured length.
Experiment: Currently unavailable.
1、Teaching objectives (knowledge preparation)
Get to know distance sensors, understand their control and usage methods.
Implement distance measurement using distance sensors through programming.
Being able to combine real-life application scenarios and apply project devices to achieve intelligent application scenarios in daily life.
2、Teaching tasks
Build a device that can use distance sensors for distance measurement.

3、Preparation of teaching environment and equipment
Equipment List: Image (with label number 123456)
Equipment Serial Number Table
| Serial number | number | equipment | Specifications | quantity |
| 1 | Motion | 1 | ||
| 2 | Four digit digital tube | 1 | ||
| 1 |
Software: Smart Code programming software.
Hardware: SMART Code kit: Motion, Four digit digital tube.
Other: Several building block devices.
Detailed List of Structural Components
| Serial number | number | equipment | Specifications | quantity |
| 1 | 3-hole beam | 12 | ||
| 2 | 7-hole beam | 4 | ||
| 3 | 13-hole beam | 4 | ||
| 4 | T-shaped beam | 4 | ||
| 5 | Black sales | 36 |
Note: Materials required to fix a set of sensors: 6 3-hole beams, 2 7-hole beams, 2 13 hole beams, 2 T-shaped beams, and 18 black pins.
4、Project Practice Process
(Summary of Knowledge Points: 1. Components. 2. Program Modules. 3. Program Design)
- Project video (in video format)
- Project Steps
- According to the item list, a fixed distance sensor and a four digit digital tube are required.
- Design the structural equipment for the handheld distance measuring device.
- Four digital tubes display distance information.
- Use SMART Code to program and control devices.
Firstly, create a program entry and initialize the four digit digital display value. The example code is as follows:
Then, loop to obtain the distance sensor values, with a time interval of 500ms, and display the distance values on the four digital sensors. The example code is as follows:
Finally, complete all the logic. The example code is as follows:

5.Optimization and improvement plan.
6.Run the program to verify if the week and display match.
7.Optimization and improvement plan.
8.Interesting Thinking: Interesting Thinking: Exploring the Accuracy of Distance Measuring Devices.
5.Optimization and improvement plan.
6.Run the program to verify if the week and display match.
7.Optimization and improvement plan.
8.Interesting Thinking: Interesting Thinking: Exploring the Accuracy of Distance Measuring Devices.
3.Reflection and discussion: Can multiple counting function be achieved?
Experimental results
Data records: Table 1 and Table 2
Experimental conclusion:
5、Extension and Expansion
Reflection and exploration:
Question 1:
Question 2:
