Value of the line-follower sensor

Author: Yisong Xu, Si Xu

Display, by a panda speaking, the value of the line-follower sensor on the stage in real time.

Hardware requirements:



Online debugging (serial/Bluetooth connection)

Example program download:

Value of line-follower sensor


Example: Kids programming language
coding robots for kids


Script description
Please refer to Example 11 Value of the light sensor.


Knowledge points
Point 1 Principles of the line-follower sensor
The line-follower sensor is below the robot (see the attached diagram), which consists of two sensors, Sensor 1 and 2, each consists of an infrared emitter and an infrared receiver (see the attached diagram). As it is often used to keep the robot moving straight, it is called a line-follower sensor. Its detection range is 1 to 2 cm.
The infrared emitter continually emits infrared light during the mBot moving:
If the infrared light is reflected (encountering white or other light color surfaces), the receiver receives the infrared signal and output the value 1 (now you can see the blue LED on the back of the line-follower sensor is lighted); if the infrared light is absorbed or cannot be reflected, the receiver will not receive the infrared signal but output the value 0.
According to the following table, it can be known that the value of the line-follower sensor can be four only: 0, 1, 2, and 3.
  Whether the receiver reveives the reflected infrared signal Value returned by Sensor 1 Value returned by Sensor 2 Represented in binary Binary to decimal
 (the value shown on the stage by the sensor)

Sensor1 Sensor2
Situation 1 Not received Not received 0 0 00 0
Situation 2 Not received Received 0 1 01 1
Situation 3 Received Not received 1 0 10 2
Situation 4 Received Received 1 1 11 3

Point 2 When there is no object in front of the line-follower sensor or the object is far away from the sensor, what value is on the line-follower sensor? 

When there is no object or the object is far away from the sensor, the infrared light cannot be reflected or the signal reflected is poor. It is deemed that Sensor 1 and 2 do not receive any infrared signal and the returned value is 0. So according to Situation 1 in the above table, the value of the line-follower sensor should be 0.


Extended tasks
Place a black paper and a white paper in front of the line-follower sensor respectively, and watch the reads on the stage as shown by the line-follower sensor.


Attached – line-follower sensor structure diagram

coding robots for kids

coding robots for kids

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

—— More examples



# Kids programming language # arduino download # how to make game on scratch # scratch 2.0 #  scratch 3.0# Scratch download