Class UltrasonicSensor
In: lib/sensors/ultrasonic_sensor.rb
Parent: Sensor

Methods

Classes and Modules

Class UltrasonicSensor::UnmeasurableDistance

Constants

INCHES_PER_CM = 0.3937008

Public Class methods

Public Instance methods

Return the measured distance in the default units (the default units being centimeters). A value of 255 is returned when the sensor cannot get an accurate reading (because the object is out of range, or there is too much interference, etc.) Note that the sensor’s real-world range is at best 175 cm. At larger distances it will almost certainly just return 255.

Same as get_distance, but raises an UnmeasurableDistance exception when the sensor cannot accurately determine the distance.

get_distance_in_cm()

Alias for get_distance

get_distance_in_cm!()

Alias for get_distance!

Return the measured distance in inches.

[Validate]