Our Goal


Material


Background Knowledge


Principle of Line Tracking

Hardware Connection


Connect the left sensor(S1) on line tracking module to the 4th pin on motor:bit. And connect the right sensor(S2) to 3rd pin. See picture below.

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

Step 3

Program

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

You can also download it from the page below.


Note: Due to the effect of inertia, the car will rush out a certain distance before stop when a black line is detected.

Result


Think


FAQ


Relative Readings