Package jpigpio.sensors
Class HC_SR04
java.lang.Object
jpigpio.sensors.HC_SR04
public class HC_SR04
extends java.lang.Object
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description long
getDelay()
Get the delay in microseconds for a trigger/echodouble
getImperialDistance()
Get the distance in inches of detection or -1 if no object detected.double
getMetricDistance()
Get the sensor measured distance to the target in meters.
-
Constructor Details
-
HC_SR04
Construct the object for this class.- Parameters:
pigpio
- The reference to the Pigpio controller- Throws:
PigpioException
-
-
Method Details
-
getDelay
Get the delay in microseconds for a trigger/echo- Returns:
- The time in microseconds between a trigger and an echo response
- Throws:
PigpioException
- on pigpiod error
-
getMetricDistance
Get the sensor measured distance to the target in meters.- Returns:
- The distance to the target in meters or -1 if not determined.
- Throws:
PigpioException
- on pigpiod error
-
getImperialDistance
Get the distance in inches of detection or -1 if no object detected.- Returns:
- The distance in inches to object.
- Throws:
PigpioException
- on pigpiod error
-