61. Case 60: Raising the National Flag#

61.1. Introduction#

We deeply love our country, and the symbols that best represent our country are the national flag that we often see and the national anthem that we often hear, in this lesson we will do the case of raising the national flag to express our love for our country, let’s start.

../../_images/60_1.jpg

Materials Required#

Nezha expansion board × 1

micro:bit V2 × 1

RJ11 cable × 1

Bricks × n

Note: If you want all of the above components, you may purchase the Nezha 48 IN 1 Inventor’s Kit.

Assembly Steps#

Component Details

../../_images/60_2.jpg

Build it as the assembly steps suggest:

../../_images/60_3.jpg

../../_images/60_4.jpg

../../_images/60_5.jpg

../../_images/60_6.jpg

../../_images/60_7.jpg

../../_images/60_8.jpg

../../_images/60_9.jpg

../../_images/60_10.jpg

../../_images/60_11.jpg

../../_images/60_12.jpg

../../_images/60_13.jpg

../../_images/60_14.jpg

../../_images/60_15.jpg

61.2. Connection Diagram#

Connect the four motors to the M1.

../../_images/60_16.jpg

61.3. MakeCode Programming#

Step 1#

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

../../_images/49_10.png

For programming the servo, we need to add a package. Click “Extensions” at the bottom of the drawer and search with “nezha” to download it.

../../_images/49_11.png

For programming the PIR sensor, we need to add a package. Search with “PlanetX” in the dialogue box and click to download it.

../../_images/49_12.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.

Reference#

The program is shown below:

../../_images/60_17.jpg

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

You may also download it directly:

Result#

We can see that when the A button is pressed, the music is played as the flag rises, and when the B button is pressed, the flag falls.

../../_images/60_18.gif