Skip to main content

Case 05 Color Recognition Lights


This lesson will take students through the process of creating a colour recognition light using the Nezha Inventor's Kit V2 and the AI Accessories Pack. By learning about colour recognition techniques, students will be able to make the light change according to the recognised colours to create unique lighting effects.

Teaching Objectives

  • Understand the basic principles of colour recognition.
  • Learn to use the AI lens for colour recognition.
  • Master the method of combining colour recognition with lighting control.
  • To develop students' hands-on practical ability and innovative thinking.

Teaching Preparation

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 colour recognition technology? What are its real-life applications? How can this technology be used in an interesting device, such as a colour recognition lamp? Through these questions, students' interest is stimulated and they are led to think about how to combine technology with creativity.

Hi everyone, today we will be working together to create a very interesting project - a colour recognition lamp. This lamp can produce different lighting effects according to the colour changes recognised. For example, when a red card is recognised, the light will turn red; when a blue card is recognised, the light will turn blue. So, how is this colour recognition light achieved? Let's explore together!


In groups, students will be asked to think about how an AI lens can be used to create a colour recognition lamp, focusing on the use of the colour recognition feature and possible scenarios for the use of colour recognition technology in their lives.

  • How does the AI lens recognise colours?
  • What are the practical applications of colour recognition technology?


Groups work in groups to make a colour recognition lamp from building blocks according to their own design.

Make a colour recognition lamp from building blocks according to your own design.


Building Steps

Assembly Completed

Hardware Connections

Connect the rainbow LED to J1 and the AI lens to the IIC port on Nezha expansion board.

Software Programming

Go to makecode

Create New Project

Click Extensions

Search with planetx and download the package.



You may download it directly below:

Teamwork and Presentation

Students are divided into teams to work together on the production and programming of the case.

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

Each team will have the opportunity to present the cases they have produced to the other teams.

Example case effect

Drop a colour card under the lens and the rainbow ring of lights will automatically change colour according to the recognised colour.


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.

Extended knowledge

Fundamentals of Colour Recognition Technology

The basic principle of colour recognition technology is based on image processing and computer vision. It captures images through a lens, and then uses algorithms to identify and analyse the colours in the images, so as to achieve the recognition of colour attributes.

Specifically, the colour recognition technique first preprocesses the image, including operations such as image enhancement, denoising and normalisation, to improve the quality and recognition accuracy of the image. Then, by analysing the colour values of each pixel, the RGB (Red, Green and Blue) values of each pixel can be obtained. RGB values are a common way of describing colours, which indicate the brightness of red, green and blue respectively. By calculating and comparing the RGB values, the colour properties of a pixel can be determined.

Some of the commonly used colour recognition methods are threshold based colour recognition, colour based colour recognition and image segmentation based colour recognition. Among them, threshold-based colour recognition is one of the simplest methods, which classifies the colours in an image into different categories by setting different thresholds. Colour based colour recognition is a recognition method based on the distributional features of colours, which achieves colour recognition by statistical and distributional analysis of the colours of each pixel in an image. Whereas, colour recognition based on image segmentation is a segmentation based on colour in the whole image to get the colour attributes of different regions.

Practical applications of colour recognition technology in real life

Colour recognition technology has a wide range of applications in real life, the following are a few common examples:

Industrial production: In industrial production, colour recognition technology can be used for product quality detection, for example, in the pharmaceutical, food, chemical and other industries, through the colour recognition technology to automate the detection of products to ensure product quality and stability.

Traffic industry: In the traffic industry, colour recognition technology can be used for traffic light identification and traffic congestion detection. For example, by analysing traffic images captured by cameras through colour recognition technology, automatic identification of traffic signals and detection of traffic congestion can be achieved, improving traffic efficiency.

Retail: In the retail industry, colour recognition technology can be used for product identification and sales analysis. For example, by analysing the images of commodities taken by cameras with colour recognition technology, automatic identification of commodities and sales statistics can be achieved, thus improving sales efficiency and management level.

Medical industry: In the medical industry, colour recognition technology can be used for pathological image analysis and disease diagnosis. For example, by analysing pathological images with colour recognition technology, automatic diagnosis of diseases and monitoring of conditions can be achieved, improving medical level and efficiency.

Smart Home: In the smart home, colour recognition technology can be used for intelligent lighting control and environmental monitoring. For example, by identifying and analysing the colour of ambient light through colour recognition technology, automatic adjustment of intelligent lighting and monitoring of ambient temperature and humidity can be achieved, improving living comfort and energy saving.

These examples show that colour recognition technology has a wide range of applications in various fields, bringing convenience and benefits to people's life and work.