Skip to main content

Case 19 Counting Basketball Frame


In this project, we will use Nezha Inventor Kit V2 to make a model basketball hoop that will automatically count the number of goals scored. We will learn how the ultrasonic sound sensors work, the circuit connections, programming and apply them to the model basketball hoop.

Teaching Objectives

  • Learn how ultrasonic sensors work
  • Learn to detect and count basketball goals using Nezha Inventor Kit V2
  • Develop creativity and innovative thinking ability

Teaching Preparation

Nezha Inventor's Kit V2

Teaching Process


Introduce students to the background and objectives of the counting basketball hoop production to stimulate their interest and curiosity.

Basketball is a very popular sport and scoring a goal every time you shoot a basket is a sense of achievement. But how interesting and practical an invention would it be if we could make a model of a basketball hoop that automatically counts the number of goals scored?


Discuss in groups and get students thinking about how to build a counting basketball hoop using the blocks.

  • How do you connect an ultrasonic sound sensor to the circuit and implement the detection of basketball goals?
  • How can the ultrasonic sound sensor detection be programmed to convert the results into a goal count?
  • How do you design a reliable goal counting mechanism that ensures accurate counting of each goal scored?
  • How to get creative and design an attractive model of a basketball hoop that can automatically display the number of goals scored?


Work in groups to build a counting basketball hoop from building blocks according to your own design.

Build a counting basketball hoop from blocks according to your own design.


Assembly Steps


Hardware Connections

Connect the ultrasonic sound sensor to J1 port on Nezha breakout board.

Software Programming

Go to makecode

Create New Project

Click Extensions

Search for PlanetX in the dialogue box to add the extension library for the PlanetaX sensors.



You may download it directly below:


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

Results of the Examples

The ball is put into the basket frame and the unit automatically counts and displays it on the LED matrix.


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.