Skip to main content

Case 04 AI Balls Classifier


This lesson will lead students to create an AI balls classifier using the Nezha Inventor Kit V2 and the AI Accessories Pack. We will learn the basic principles of object recognition and classification, and develop comprehensive STEAM skills through hands-on practice.

Teaching Objectives

  • Understand the principles of object recognition and classification.
  • Learn to build and programme hardware using the Nezha Inventor Kit V2 and AI Accessories Pack.
  • Develop students' teamwork and problem-solving skills.

Teaching Preparations

Nezha Inventor's Kit V2

AI Accessories Pack

A Computer

Teaching Process


The teacher can guide students to think about the following questions: what is object recognition technology? What are its real-life applications? How can this technology be applied to an interesting device, such as an AI balls classifier? Through these questions, students' interest is stimulated and they are led to think about how to combine technology with creativity.

In our daily life, there are many items that need to be sorted and organised. Today, we will work together to create a ball classifier that recognises the colours of the blobs through the AI lens and sorts them automatically. Let's learn how to use our STEAM knowledge to combine technology with life!


Group discussion to get students to think about how to create an AI balls classifier using an AI lens, focusing on the use of the blob recognition feature and possible application scenarios of item recognition in life.

  • How does an AI lens recognise and classify blobs?
  • How to program the control of the operation of the balls classifier?
  • How to optimise the accuracy and efficiency of the balls classifier?


Work in groups to create an AI balls classifier from building block materials according to your own design scheme.

Follow your own design scheme to create an AI balls classifier using building block materials.


Assembly Steps

Assembly Finished

Hardware Connections

Connect the servo to S1 and the AI lens to the IIC port on Nezha expansion board.

Software Programming

Go to makecode

Create New Project

Click "extensions"

Search with nezha and download the extension.

Search with planetx and download the extension.



You may download it directly below:

Teamwork and Display

Students are divided into small groups and work together to create and programme the case.

Students are encouraged to co-operate, communicate and share their experiences with each other.

Each group has the opportunity to present the cases they have produced to the other groups.

Examples Cases Result

Place the ball on the slide of the ball classifier and the ball sorter will automatically sort the balls according to their colour.


Sharing in groups allows students in each group to share their production process and insights, summarise the problems and solutions they encountered, and evaluate their strengths and weaknesses.

Extended Knowledge

What is Object Recognition?

Item recognition is an important branch in the field of machine learning, and its principle is based on feature extraction and classification of image data of items. Specifically, an item recognition system learns various features of an item by training the image data using deep learning algorithms, and classifies and recognises new item images based on these features in a subsequent process.

First, the item recognition system preprocesses the image data, including operations such as image enhancement, image cropping, and colour space conversion, in order to better extract the features of the item. Next, the system performs feature extraction on the image data using deep learning algorithms to convert the image into vectors with specific features. These features may include the shape, texture, colour, etc. of the object.

Next, the object recognition system uses a classifier to classify these feature vectors. The classifiers can use various machine learning algorithms such as Support Vector Machines (SVMs), Random Forests, Neural Networks, etc. By training these classifiers, the system is able to correctly classify the items based on their features.

Finally, the item recognition system generates corresponding item labels or names based on the classification results. These labels can be used in various application scenarios such as subsequent item recognition, item search, and item recommendation.

It should be noted that the accuracy and efficiency of item recognition depends on a variety of factors, including image quality, feature selection, training dataset size and diversity. Therefore, these factors need to be taken into account when designing and developing an item recognition system in order to improve the accuracy and robustness of the system.