69. Case 65: Drum Beater#

69.1. Introduction#

Use Nezha 48 IN 1 Inventor’s Kit and trimpotto build the drum machine that can control the speed with a knob.

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

69.2. Case building#

Materials Required#

Nezha 48 IN 1 Inventor’s Kit

trimpot

Structure Construction#

Parts List

../../_images/neza-inventor-s-kit-case-65-02.png

The structure is built as shown in the figure.

../../_images/neza-inventor-s-kit-step-65-01.png

../../_images/neza-inventor-s-kit-step-65-02.png

../../_images/neza-inventor-s-kit-step-65-03.png

../../_images/neza-inventor-s-kit-step-65-04.png

../../_images/neza-inventor-s-kit-step-65-05.png

../../_images/neza-inventor-s-kit-step-65-06.png

../../_images/neza-inventor-s-kit-step-65-07.png

../../_images/neza-inventor-s-kit-step-65-08.png

../../_images/neza-inventor-s-kit-step-65-09.png

../../_images/neza-inventor-s-kit-step-65-10.png

../../_images/neza-inventor-s-kit-step-65-11.png

../../_images/neza-inventor-s-kit-step-65-12.png

../../_images/neza-inventor-s-kit-step-65-13.png

../../_images/neza-inventor-s-kit-step-65-14.png

../../_images/neza-inventor-s-kit-step-65-15.png

../../_images/neza-inventor-s-kit-step-65-16.png

../../_images/neza-inventor-s-kit-step-65-17.png

../../_images/neza-inventor-s-kit-step-65-18.png

../../_images/neza-inventor-s-kit-step-65-19.png

../../_images/neza-inventor-s-kit-step-65-20.png

../../_images/neza-inventor-s-kit-step-65-21.png

../../_images/neza-inventor-s-kit-step-65-22.png

../../_images/neza-inventor-s-kit-step-65-23.png

../../_images/neza-inventor-s-kit-step-65-24.png

../../_images/neza-inventor-s-kit-step-65-25.png

Finished picture:

../../_images/neza-inventor-s-kit-step-65-26.png

69.3. Connection Diagram#

Connect the trimpot to J1 port, and the Motor to M1 port on Nezha Breakout Board .

../../_images/neza-inventor-s-kit-case-65-03.png

69.4. MakeCode Programming#

Step 1#

Click “Advanced” in the MakeCode drawer to see more choices.

../../_images/neza-inventor-s-kit-case-37-04.png

For programming the potentiometer, we need to add an extension library. Type “PlanetX” in the dialog box and click Search, then click 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. Type “Nezha” in the dialog box and click Search, then click to download this code library.

../../_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 picture suggests#

../../_images/neza-inventor-s-kit-case-65-07.png

Reference#

Link: https://makecode.microbit.org/_L7shxbLtVJYY

You may also download it directly:

Result#

The knob trimpot allows you to control the rhythm of the drummer’s strikes.

../../_images/neza-inventor-s-kit-case-65.gif