Skip to content

Search the documentation

Kit
Firmware

DistanceSensor

Mini

Measures how far away something is. It sends out a short burst of ultrasound, a sound too high for us to hear, and times how long the echo takes to come back, like a bat.

The DistanceSensor class is reached through this attribute of robot.

Can be None until you call robot.enable_distance_sensor().

All the attributes of robot are in its table. Read Attributes that can be None to see when a part is None.

How far the nearest object is, in centimetres; -1 when the reading fails.

distance_cm() -> float

Used in examples: Mini eyes

How far the nearest object is, in millimetres; -1 when the reading fails.

distance_mm() -> int

True when something is within_cm centimetres away or closer (default 10).

sees_object(within_cm: int) -> bool

You can leave out within_cm.