## Let me down

23,001
Author: Yisong Xu, Si Xu

Put mBot on a light color table. Once mBot is picked up, it continually sounds an alarm.

Hardware requirements:

mBot

Implementation:

Let me down.sb2

#### Script description In Example 21 Value of line-follower sensor we introduced the principles of the line-patrolling sensor, of which the detection range is from 1 to 2 cm.

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 consisting 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.
After that, 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 revives 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) Sensor 1 Sensor 2 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 If  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.

If you take 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); at the moment that mBot is picked up to be 1-2 cm from the table surface, which exceeds the detection range, the infrared light cannot be reflected and the values is 0 (both Sensor 1 and Sensor 2 output 0).
When the value of the line-patrolling sensor is 0, it can be deemed that mBot is picked up and it will sound an alarm.