Class Buzzer

All Implemented Interfaces:
OutputDeviceInterface, Closeable, AutoCloseable

public class Buzzer
extends DigitalOutputDevice
Represents a digital buzzer component.
  • Constructor Details

    • Buzzer

      public Buzzer​(int gpio) throws RuntimeIOException
      Parameters:
      gpio - The GPIO to which the buzzer is attached to.
      Throws:
      RuntimeIOException - If an I/O error occurred.
    • Buzzer

      public Buzzer​(int gpio, boolean activeHigh) throws RuntimeIOException
      Parameters:
      gpio - The GPIO to which the buzzer is attached to.
      activeHigh - Set to true if a high output value represents on.
      Throws:
      RuntimeIOException - If an I/O error occurred.
  • Method Details

    • beep

      public void beep() throws RuntimeIOException
      Beep repeatedly in a background thread.
      Throws:
      RuntimeIOException - If an I/O error occurred.
    • beep

      public void beep​(float onTime, float offTime, int n, boolean background) throws RuntimeIOException
      Beep.
      Parameters:
      onTime - On time in seconds.
      offTime - Off time in seconds.
      n - Number of iterations. Set to <0 to beep indefinitely
      background - If true start a background thread to control the blink and return immediately. If false, only return once the blink iterations have finished.
      Throws:
      RuntimeIOException - If an I/O error occurred.