5. Case 01:The Mechanical Shrimp¶
5.1. Introduction¶
Build a mechanical shrimp with the Nezha Inventor’s Kit.
5.2. Quick to Start¶
Materials Required¶
Connection Diagram¶
Connect the Ultrasonic Sensor to J1, the geekservo to S1 and the two motors to M1 and M4 on Nezha Breakout Board.
5.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, the mechanical shrimp moves forward and waves the princers, it will turn the directions if there is obstacles being detected.