Cliff detection

12,926
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:how to make games on scratch 
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); At the moment that 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. #how to make games on scratch#
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-patrolling sensor structure diagram

programming for kids

programming for kids

# arduino download # coding robots for kids # scratch download # scratch 2.0 # kids programming language # how to make games on scratch # scratch 3.0