Package com.diozero.devices
Class Buzzer
java.lang.Object
com.diozero.api.GpioDevice
com.diozero.api.DigitalOutputDevice
com.diozero.devices.Buzzer
- All Implemented Interfaces:
DeviceInterface
,OutputDeviceInterface
,AutoCloseable
public class Buzzer extends DigitalOutputDevice
Represents a digital buzzer component.
-
Field Summary
Fields inherited from class com.diozero.api.DigitalOutputDevice
INFINITE_ITERATIONS
Fields inherited from class com.diozero.api.GpioDevice
pinInfo
-
Constructor Summary
-
Method Summary
Methods inherited from class com.diozero.api.DigitalOutputDevice
close, isOn, off, on, onOffLoop, setOn, setValue, setValueUnsafe, toggle
Methods inherited from class com.diozero.api.GpioDevice
getGpio
-
Constructor Details
-
Buzzer
- Parameters:
gpio
- The GPIO to which the buzzer is attached to.- Throws:
RuntimeIOException
- If an I/O error occurred.
-
Buzzer
- 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
Beep repeatedly in a background thread.- Throws:
RuntimeIOException
- If an I/O error occurred.
-
beep
Beep.- Parameters:
onTime
- On time in seconds.offTime
- Off time in seconds.n
- Number of iterations. Set to <0 to beep indefinitelybackground
- 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.
-