Introduction: Use color sensors, four-way digital tubes, and RGB lights to recognize three colors.
Advanced: Intelligent sorting speed adjustment. Simulate the sorting effect of express delivery by combining motors and servos. Electric motors can be used for conveyor belts.
Advanced: Visual recognition for item classification.
Experiment: Physics Experiment: Color Display, Propagation of Light, Direct and Reflection.
1、Teaching objectives (knowledge preparation)
Master the color calibration method of color sensors. (The color sensor can recognize up to 3 colors, and each color needs to be calibrated separately. Calibration method: Press and hold the button on the color sensor. When the red light in the upper left corner flashes, place the color that needs to be calibrated, and then press the button briefly until the upper left corner light stays on, indicating successful recognition. Then you can test the calibration results.)
The control and use of color sensors can be achieved through programming.
Can be combined with real-life application scenarios and project devices.
2、Teaching tasks
Using color sensors, four-way digital tubes, and RGB lights, achieve recognition of three colors and display them on the RGB lights. The three colors correspond to values of 1, 2, and 3. If the recognition is not successful, the color sensor returns a value of 0.

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 | Color Recognition | 1 | ||
| 2 | Four-digit Display | 1 | ||
| 3 | RGB Light | 1 | ||
Software: Smart Code programming software.
Hardware: SMART Code kit: Color Recognition, Four-digit Display, RGB Light.
Other: Several building block devices.
Detailed List of Structural Components
| Serial number | number | equipment | Specifications | quantity |
| 1 | 3-hole beam | 18 | ||
| 2 | 7-hole beam | 6 | ||
| 3 | 13-hole beam | 6 | ||
| 4 | T-shaped beam | 6 | ||
| 5 | Black sales | 54 |
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)
1.Project video (in video format)
2.Project Steps
1.Fixed color sensor with four-way digital tube and RGB light.
2.Use SMART Code software for programming.
Firstly, create a program entrance. The example code is as follows:
Then, display the value 0 of the color sensor’s undetected color status on the four-way digital display. The example code is as follows:
Then, manually mark 3 colors, you can try marking red, green, and blue.
Then, after successful marking, make a judgment in the program and display the corresponding marked color on the RGB light. The example code is as follows:
Finally, complete the entire code. The example code is as follows:

3.Interesting thinking: Identify different values of color feedback and find patterns.
3.Reflection and discussion: What are the factors that affect the success rate of color sensor recognition?
Experimental results
Data records: Table 1 and Table 2
Experimental conclusion:
5、Extension and Expansion
Reflection and exploration:
Question 1:
Question 2:
