Cliff detection

11,981
Author: Yisong Xu, Si Xu

Let mBot move forward on a white table (or other light color table) and stop it when it gets to the edge of the table surface.

Hardware requirements:

mBot

Implementation:

Upload the program to Arduino

Example program download:

Cliff detection.sb2

download

Example programs
programming for kids

 

Script description
When mBot travels within the surface of the white table (or other light color table), the line-patroling sensor can receive the returned infrared signal and the value is 3 (both Sensor1 and Sensor2 return 1); when mBot travels to the edge of the table surface, the line-patroling sensor cannot receive the reflected infrared light and the value is 0 (both Sensor1 and Sensor 2 return 0). When the value of the line-patroling sensor is 0, it is deemed to have reached the edge of the table surface and will be stopped.
Also if you use this program, mBot will stop moving forward when it detects black.

 

Extended tasks

Task 1 Modify the script to let mBot move back when it detects a cliff.
Task 2 Modify the script and use block to achieve the effects of this example.

 

Attached – Line-patroling sensor structure diagram

programming for kids

programming for kids