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.

e9a18217-1296-4d80-9de6-7c9ceb7cf6dd.gif

 

Part 2 Preparation

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

55fc64d2-9018-49ab-9a13-78207cdaa64c.gif

  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".

1f42779c-3046-4fab-ae3c-a69ac96b1cc3.gif

 

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.

8ef9b85d-4f46-4d7d-aa32-35224bd5e96b.gif

Source program diagram

3dcd4c4d-450d-45d5-bf34-f9438f02bf2c.png

 

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

Comments

0 comments

Please sign in to leave a comment.