DistanceSensor
MiniMeasures 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.
How you reach it
Section titled “How you reach it”The DistanceSensor class is reached through this attribute of robot.
robot.distance_sensor
Section titled “robot.distance_sensor”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.
Methods
Section titled “Methods”distance_cm()
Section titled “distance_cm()”How far the nearest object is, in centimetres; -1 when the reading fails.
distance_cm() -> floatUsed in examples: Mini eyes
distance_mm()
Section titled “distance_mm()”How far the nearest object is, in millimetres; -1 when the reading fails.
distance_mm() -> intsees_object(within_cm)
Section titled “sees_object(within_cm)”True when something is within_cm centimetres away or closer (default 10).
sees_object(within_cm: int) -> boolYou can leave out within_cm.