Skip to main content

Case 11 The Crab Robot


Crabs are creatures that live in the sea and fresh water and have hard shells and powerful pincers. Crabs move mainly by walking laterally and they crawl through the coordinated movement of their legs. In this lesson we will learn about the characteristics and behaviour of crabs and try to make a mechanical crab that mimics the crab's crawl.

Teaching Objectives

  • Understand the working principles and applications of ultrasonic sound sensors.
  • Learn the basic principles of gearing and how to implement it.
  • Learn how to use ultrasonic sensors and gearing to create a mechanical crab that mimics the crawling of a crab.
  • Develop creativity, problem-solving skills and teamwork spirit.

Teaching Preparation

Nezha Inventor's Kit V2

Teaching Process


Introduce students to the background and objectives of the mechanical crab production to stimulate their interest and curiosity.

Is everyone interested in crabs? Crabs are interesting creatures that crawl freely in the ocean and in fresh water. Today, I have brought along a special project where we will be using Nezha Inventor's Kit V2 to create a mechanical crab that mimics the crab's crawl. This mechanical crab has an intelligent function that will automatically walk sideways when it detects an obstacle in front of it. Through this project, we will learn how to apply ultrasonic sound sensors and gearing to make an interesting mechanical crab.


In groups, get students thinking about how to make a mechanical crab from block materials, focusing on how the ultrasonic sound sensor works.

  • How do crabs perform lateral walking? What are their characteristics and patterns?
  • How does an ultrasonic sound sensor work? What can it detect?
  • What is the gear transmission? What is its role in the mechanical crab?
  • How can the mechanical crab be programmed by Nezha Inventor's Kit V2 to walk sideways according to the signals from the ultrasonic sound sensor?


Work in groups to create a mechanical crab from block materials following your own design.


Assembly Steps


Hardware Connections

Connect the ultrasonic sound sensor to the J1 and the motor to the M1 connector of the Nezha expansion board.


Go to makecode

Create New Project

Click "Extensions"

Search wih PlanetX to add the package.

Search with nezha to add the package.



You may download it directly:


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


When an obstacle stands in the way of the crab, the crab will walk to the side way.


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.