43. Case 39:The Mechanical Crab¶
43.1. Introduction¶
Build a mechanical crab with the Nezha Inventor’s Kit.
43.2. Quick to Start¶
Materials Required¶
Assembly¶
Components List
Build it as the assembly steps suggest:
We can see that the construction is completed as shown in the following figure:
Connection Diagram¶
Connect the Ultrasonic Sensor to J1 and the motor to M1 on Nezha Breakout Board.
43.3. MakeCode Programming¶
Step 1¶
Click “Advanced” in the MakeCode drawer to see more choices.
For programming the Ultrasonic Sensor, we need to add a package. Search with “PlanetX” in the dialogue box and click to download it.
For programming Nezha Breakout Board, we need to add a package. Search with “Nezha” in the dialogue box and click to download it.
Notice: If you met a tip indicating that some codebases would be deleted due to incompatibility, you may continue as the tips say or create a new project in the menu.
Step 2¶
Code as the picture suggests¶
Result¶
After powering on, if the crab sees an approaching object ahead, it will crawl towards sideways.