25. Case 23: The Locomotive#

25.1. Purpose#


Make a locomotive.

../../_images/Wonder-Building-Kit-case-23-01.png

25.3. Materials Required#


../../_images/Wonder-Building-Kit-step-case-23-01.png

25.4. Bricks build-up#


../../_images/Wonder-Building-Kit-step-case-23-02.png

../../_images/Wonder-Building-Kit-step-case-23-03.png

../../_images/Wonder-Building-Kit-step-case-23-04.png

../../_images/Wonder-Building-Kit-step-case-23-05.png

../../_images/Wonder-Building-Kit-step-case-23-06.png

../../_images/Wonder-Building-Kit-step-case-23-07.png

../../_images/Wonder-Building-Kit-step-case-23-08.png

../../_images/Wonder-Building-Kit-step-case-23-09.png

../../_images/Wonder-Building-Kit-step-case-23-10.png

../../_images/Wonder-Building-Kit-step-case-23-11.png

../../_images/Wonder-Building-Kit-step-case-23-12.png

../../_images/Wonder-Building-Kit-step-case-23-13.png

../../_images/Wonder-Building-Kit-step-case-23-14.png

../../_images/Wonder-Building-Kit-step-case-23-15.png

../../_images/Wonder-Building-Kit-step-case-23-16.png

../../_images/Wonder-Building-Kit-step-case-23-17.png

../../_images/Wonder-Building-Kit-step-case-23-18.png

../../_images/Wonder-Building-Kit-step-case-23-19.png

../../_images/Wonder-Building-Kit-step-case-23-20.png

../../_images/Wonder-Building-Kit-step-case-23-21.png

../../_images/Wonder-Building-Kit-step-case-23-22.png

../../_images/Wonder-Building-Kit-step-case-23-23.png

../../_images/Wonder-Building-Kit-step-case-23-24.png

../../_images/Wonder-Building-Kit-step-case-23-25.png

../../_images/Wonder-Building-Kit-step-case-23-26.png

../../_images/Wonder-Building-Kit-step-case-23-27.png

../../_images/Wonder-Building-Kit-step-case-23-28.png

../../_images/Wonder-Building-Kit-step-case-23-29.png

../../_images/Wonder-Building-Kit-step-case-23-30.png

../../_images/Wonder-Building-Kit-step-case-23-31.png

../../_images/Wonder-Building-Kit-step-case-23-32.png

../../_images/Wonder-Building-Kit-step-case-23-33.png

25.5. Hardware Connection#

Connect a motor to M1 port on Wukong breakout board.

../../_images/Wonder-Building-Kit-case-23-06.png

25.6. Software Platform#


MakeCode

25.7. Coding#


Add extensions#

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

../../_images/Wonder-Building-Kit-case-21-02.png

Search with Wukong in the dialogue box to download it.

../../_images/Wonder-Building-Kit-case-21-03.png

Program#

../../_images/Wonder-Building-Kit-case-23-04.png

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

Result#

When button A is pressed, the locomotive moves forward; when button B is pressed, the locomotive moves backward; when button A+B is pressed, the locomotive stops moving.