Spring Sale: 5% OFF Over $89, Code: Elephant5; 10% OFF Over $149, Code:Elephant10



Micro python Robot Course 7: Black line control light

Posted by SuFiona on

Learning goal

This lesson learns how to use the tracking sensor on the Tiny-bit microbit robot.

Preparation:

1.The position of the tracking module in the robot, as shown below.

image.png 

!!!Note: In order to avoid the interference of sunlight on infrared sensor, we need to carry out this experiment indoors.

2. Learn about the principle of tracking module

The basic principle of the tracking sensor is to use the reflective nature of the object.

Our experiment is to tracking the black line. When the infrared light is emitted to the black line, it will be absorbed by the black line. When the infrared light is emitted to the other color line, it will reflected to the infrared receiver tube.

From the hardware interface manual, we can know that the tracking sensor is directly driven by the micro:bit P13,P14 pin.

image.png

 Code

image.png 

Programming and downloading

1.You should open the Mu software, and enter the code in the edit window, , as shown in Figure 7-1.

Note! All English and symbols should be entered in English, and the last line must be a space.

image.png 

 Figure 7-1

2.As shown in Figure 7-2, you need to click the Check button to check if our code has an error. If a line appears with a cursor or an underscore, the program indicating this line is wrong.

image.png Figure 7-2

3.You need to connect the micro data cable to micro:bit and the computer, then click the Flash button to download the program to micro:bit as shown in Figure 7-3.

image.png Figure 7-3

4. After downloading the program,

when left and right tracking sensor of Tiny-bit detect the black line, the two LED lights are yellow;

When the left line sensor of Tiny-bit detects a black line and the right tracking sensor does not detect a black line, the left LED light is yellow and the right LED light is blue;

When the left line sensor of Tiny-bit does not detect the black line and the right tracking sensor detects the black line, the left LED light is blue, and the right LED light is yellow;

when left and right tracking sensor of Tiny-bit do not detect the black line, the two LED lights are blue;

The code of the experiment: 7.Blackline control light.zip

Micro python Robot Course:

0 comments

Leave a comment

Please note, comments must be approved before they are published