Distance#

Introduction#

The Distance Sensor allows your robot to detect the presence of an object and measure its distance.

Below is a list of available blocks:

Distance found object?#

The Distance found object? block returns a Boolean indicating whether the Distance Sensor has detected an object within 2000 mm.

  • True – The Distance Sensor has detected an object.

  • False – The Distance Sensor has not detected an object.

<[FrontDistance v] 发现对象?>

Parameters

Description

distance sensor

Which Distance Sensor to use.

Example

当开始 :: hat events
[Spin until the Distance Sensor detects an object.]
[右 v] 转
等到 <[FrontDistance v] 发现对象?>
驱动停止

object distance#

The object distance returns the distance of the nearest object from the Distance Sensor.

([FrontDistance v] 距离 [毫米 v])

Parameters

Description

distance sensor

Which Distance Sensor to use.

unit

The unit of measurement, which can be one of the following:

  • mm (millimeters)
  • inches

Example

当开始 :: hat events
[Don't print the message until the Distance Sensor detects an object.]
[右 v] 转
等到 <[FrontDistance v] 发现对象?>
驱动停止
打印 ([FrontDistance v] 距离 [毫米 v]) ▶