Case 7- Read the value of line following sensor

Part 1 Objective

User writes a program to display the values detected by the line following sensor in real time on the stage area.



Part 2 Preparation

  • mBot x1
  • USB cable x1
  • Computer with network access
  1. Use a data cable to connect the mBot to the computer.


  1. Open MBlock5 (PC, Web, APP), click "Add" in the lower left device area, select mBot in the device library, and click “Connect”.(Live mode: you can click the building block to observe the real-time running effect, but you need to keep the data cable connected to the computer; Upload mode: You can upload the program to mBot, at which time you can unplug the data cable to run the program. ), this course needs to switch to "Live mode".



Part 3 Programming

Create a new variable and name it "Line Patrol Value" to store the value detected by the Line Patrol sensor, select it to be displayed on the Stage in real time. Please correctly select the interface number that matches the sensor connection interface.


Source program diagram



Part 4 Procedure source code

Get line follower sensor value.mblock


Part 5 Practice

  1. User places black and white paper under the line sensor and observes the change in the reading of the line sensor in the stage area.
  2. Put a different color of paper under the line line sensor and observe whether the reading of the line line sensor on the stage changes.
Was this article helpful?
0 out of 0 found this helpful



Please sign in to leave a comment.