75. Case 71: Blocks Sorting Machine#

75.1. Introduction#

Use ELECFREAKS micro:bit Nezha 48 IN 1 Inventor’s Kit with ELECFREAKS Interactive Coding Accessories Pack to make a block sorting machine.

../../_images/neza-inventor-s-kit-case-71-01.png

75.2. Case Building#

Materials Required#

ELECFREAKS micro:bit Nezha 48 IN 1 Inventor’s Kit

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

75.3. 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

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