Our Goal


Material


Background Knowledge


What is ultrasonic wave?

Principle of Ultrasonic Distance Measurement

Hardware Connection


Connect sonar:bit to P10 on motor:bit.

Software


Microsoft MakeCode

Programming


Step 1

Click Advanced in the code drawer of MakeCode to see more options.

To program for motor:bit, we have to add a package. Find Add Package in the bottom of code drawer and click it. This will pop up a dialogue box. Search for “motorbit” and then click to download this package.

Note: If you get a hint that some packages will be deleted due to the problem of incompatibility, you can either follow the prompts, or create a new project in the project menu.

Step 2

Program

Link of the whole program: https://makecode.microbit.org/_bW1ThbRWsdMP

You can also download it from the page below.


Result


Think


FAQ


Relative Readings