Class Servo

java.lang.Object
com.diozero.api.GpioDevice
com.diozero.devices.Servo
All Implemented Interfaces:
OutputDeviceInterface, Closeable, AutoCloseable

public class Servo
extends GpioDevice
implements OutputDeviceInterface
  • Constructor Details

  • Method Details

    • getOutputDeviceUnit

      public Servo.OutputDeviceUnit getOutputDeviceUnit()
    • setOutputDeviceUnit

      public Servo setOutputDeviceUnit​(Servo.OutputDeviceUnit outputDeviceUnit)
    • setInverted

      public Servo setInverted​(boolean inverted)
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • getPwmFrequency

      public int getPwmFrequency()
    • getValue

      public float getValue()
    • setValue

      public void setValue​(float value)
      Description copied from interface: OutputDeviceInterface
      Sets the output value of the device.
      Specified by:
      setValue in interface OutputDeviceInterface
      Parameters:
      value - the value to output
    • getPulseWidthMs

      public float getPulseWidthMs()
      Get the current servo pulse width in milliseconds
      Returns:
      The servo pulse width (milliseconds)
    • setPulseWidthMs

      public void setPulseWidthMs​(float pulseWidthMs)
      Set the servo pulse width in milliseconds
      Parameters:
      pulseWidthMs - Servo pulse width (milliseconds)
    • getAngle

      public float getAngle()
      Get the current servo angle where 90 degrees is the middle position
      Returns:
      Servo angle (90 degrees is middle)
    • setAngle

      public void setAngle​(float angle)
      Turn the servo to the specified angle where 90 is the middle position
      Parameters:
      angle - Servo angle (90 degrees is middle)
    • min

      public void min()
    • max

      public void max()
    • centre

      public void centre()