In Example 21 Value of line-follower sensor we introduced the principles of the line-patroling sensor, of which the detection range is from 1 to 2 cm. So taking advantage of this principle, you can control mBot robots to judge from the changes in the external environment.
When mBot is placed on a white (or light color) table, the infrared light can be reflected, and the value is 3 (both Sensor1 and Sensor2 output 1); when mBot is picked up to be 1-2cm from the table surface, which exceeds the detection range, the infrared light cannot be reflected and the values is 0 (both Sensor1 and Sensor2 output 0).
When the value of the line-patroling sensor is 0, it can be deemed that mBot is picked up and it will sound an alarm.
Make mBot sound an alarm when it is picked up and show on the stage the value of the line-patroling sensor.
Attached – Line-patroling sensor structure diagram
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.