Module micromelon.ultrasonic

Functions to read from the robot's ultrasonic sensor.

Expand source code
"""
Functions to read from the robot's ultrasonic sensor.
"""
from ._ultrasonic import *

__all__ = [
    "read",
]

Functions

def read()

Returns

The number of cm to the nearest object in the ultrasonic sensor's field of view

Expand source code
def read():
    """
    Returns:
      The number of cm to the nearest object in the ultrasonic sensor's field of view
    """
    reading = _rc.readAttribute(OPTYPE.ULTRASONIC)
    return bytesToIntArray(reading, 2, signed=False)[0]