Class UltraSonicSensorHelper

java.lang.Object
com.opensourcewithslu.inputdevices.UltraSonicSensorHelper

public class UltraSonicSensorHelper extends Object
The UltraSonicSensorHelper class initializes the Ultra Sonic Sensor and provides component functionality
  • Constructor Details

    • UltraSonicSensorHelper

      public UltraSonicSensorHelper(com.pi4j.io.gpio.digital.DigitalOutput triggerPin, com.pi4j.io.gpio.digital.DigitalInput echoPin)
      Constructs a new UltraSonicSensorHelper instance.
      Parameters:
      triggerPin - The DigitalOutput pin for triggering the ultrasonic sensor.
      echoPin - The DigitalInput pin for receiving the echo from the ultrasonic sensor.
  • Method Details

    • initialize

      public void initialize()
      Initializes the Ultrasonic Sensor
    • startMeasuring

      public void startMeasuring()
      Begins measuring distance from sensor calling triggerAndMeasureDistance function every 100 milliseconds
    • getDistanceInCentimeter

      public double getDistanceInCentimeter()
      Returns the distance in centimeters.
      Returns:
      The distance value in centimeters.
    • getDistanceInMeters

      public double getDistanceInMeters()
      Returns the distance in meters.
      Returns:
      The distance value in meters.
    • stopMeasuring

      public void stopMeasuring()
      Shuts down ultrasonic sensor