# Case 71: Blocks Sorting Machine ## Introduction Use [ELECFREAKS micro:bit Nezha 48 IN 1 Inventor's Kit ](https://shop.elecfreaks.com/products/elecfreaks-micro-bit-nezha-48-in-1-inventors-kit-without-micro-bit-board) with [ELECFREAKS Interactive Coding Accessories Pack](https://shop.elecfreaks.com/products/elecfreaks-interactive-coding-accessories-pack) to make a block sorting machine. ![](./images/neza-inventor-s-kit-case-71-01.png) ## Case Building ### Materials Required [ELECFREAKS micro:bit Nezha 48 IN 1 Inventor's Kit ](https://shop.elecfreaks.com/products/elecfreaks-micro-bit-nezha-48-in-1-inventors-kit-without-micro-bit-board) [ELECFREAKS Interactive Coding Accessories Pack](https://shop.elecfreaks.com/products/elecfreaks-interactive-coding-accessories-pack) ### Structure Building Parts list ![](./images/neza-inventor-s-kit-case-71-02.png) The structure is built as shown in the figure: ![](./images/neza-inventor-s-kit-step-71-01.png) ![](./images/neza-inventor-s-kit-step-71-02.png) ![](./images/neza-inventor-s-kit-step-71-03.png) ![](./images/neza-inventor-s-kit-step-71-04.png) ![](./images/neza-inventor-s-kit-step-71-05.png) ![](./images/neza-inventor-s-kit-step-71-06.png) ![](./images/neza-inventor-s-kit-step-71-07.png) ![](./images/neza-inventor-s-kit-step-71-08.png) ![](./images/neza-inventor-s-kit-step-71-09.png) ![](./images/neza-inventor-s-kit-step-71-10.png) ![](./images/neza-inventor-s-kit-step-71-11.png) ![](./images/neza-inventor-s-kit-step-71-12.png) ![](./images/neza-inventor-s-kit-step-71-13.png) ![](./images/neza-inventor-s-kit-step-71-14.png) ![](./images/neza-inventor-s-kit-step-71-15.png) ![](./images/neza-inventor-s-kit-step-71-16.png) ![](./images/neza-inventor-s-kit-step-71-17.png) ![](./images/neza-inventor-s-kit-step-71-18.png) ![](./images/neza-inventor-s-kit-step-71-19.png) ![](./images/neza-inventor-s-kit-step-71-20.png) ![](./images/neza-inventor-s-kit-step-71-21.png) ![](./images/neza-inventor-s-kit-step-71-22.png) Completed Picture ![](./images/neza-inventor-s-kit-step-71-23.png) ### Connection Diagram Connect the Rainbow LED to J1, the color sensor to IIC and the servo to S1 on Nezha Breakout board as the picture displays. ![](./images/neza-inventor-s-kit-case-71-04.png) ## MakeCode Programming ### Step1 Click "extensions" in the MakeCode drawer. ![](./images/neza-inventor-s-kit-case-37-04.png) 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. ![](./images/neza-inventor-s-kit-case-37-05.png) For programming the Nezha expansion board, we need to add an expansion library. Search with "Nezha" in the dialog box to download it. ![](./images/neza-inventor-s-kit-case-37-06.png) *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 ### Write the program as the picture suggests ![](./images/neza-inventor-s-kit-case-71-06.png) ### Reference Link:[https://makecode.microbit.org/_3tkXK83pFDoH](https://makecode.microbit.org/_3tkXK83pFDoH) You may also download it directly:
### Result 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. ![](./images/neza-inventor-s-kit-case-71.gif)