Motorcycle-MakeCode - Micro:bit

Motorcycle-MakeCode - Micro:bit

Materials

micro:bit x 1

Wukong expansion board x 1

Motor x 1

Bricks x N

Hardware Connections

Insert the micro:bit to Wukong expansion and connect the motors to M1 and M2 ports accordingly.

Bricks Build-up

Build the bricks as the picture shows:

Software programming

Go to the MakeCode coding page:(https://makecode.microbit.org/#editor) Add wukong extension package, click extension in the menu of settings on the right upper side.

Search with“wukong”to download it .

Now let us go to the coding page: Drag show icon brick into on start.

Controlling the turning direction through button A and B. While button A being pressed, set the speed of M1 at 0, and M2 at -100, thus to make the car turn right; Then use the same way to code the car to turn left.

While button A&B being pressed, set the speed of M1 at 100 and M2 at -100.

While the screen facing to the ground, set the speed of M1&M2 at 0.

Complete program:

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

Result

Press button A to turn the car left and button B to turn the car right; press both A&B to drive the car forward; While the screen facing to the ground, the car stops moving.