Case 71: Blocks Sorting Machine
The structure is built as shown in the figure:
Connect the Rainbow LED to J1, the color sensor to IIC and the servo to S1 on Nezha Breakout board as the picture displays.
Click "extensions" in the MakeCode drawer.
For programming the potentiometer and the rainbow led，we need to add an extension library. Search with "PlanetX" in the dialog box to download this library.
For programming the Nezha expansion board, we need to add an expansion library. Search with "Nezha" in the dialog box 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.
Write the program as the picture suggests
You may also download it directly:
The color sensor is used to distinguish the color of the blocks and display them through the rainbow light ring, and the blocks are classified according to the recognized color.