Package com.diozero.devices
Class RgbLed
java.lang.Object
com.diozero.devices.RgbLed
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class RgbLed extends Object implements Closeable
Three pin controlled RGB LED.
4 3 2 1
1 Red
2 Ground
3 Green
4 Blue
-
Constructor Summary
Constructors Constructor Description RgbLed(int redPin, int greenPin, int bluePin)
RgbLed(GpioDeviceFactoryInterface deviceFactory, int redPin, int greenPin, int bluePin)
-
Method Summary
-
Constructor Details
-
RgbLed
- Parameters:
redPin
- GPIO for the red LED.greenPin
- GPIO for the green LED.bluePin
- GPIO for the blue LED.- Throws:
RuntimeIOException
- If an I/O error occurred.
-
RgbLed
public RgbLed(GpioDeviceFactoryInterface deviceFactory, int redPin, int greenPin, int bluePin) throws RuntimeIOException- Parameters:
deviceFactory
- Device factory to use to provision this device.redPin
- GPIO for the red LED.greenPin
- GPIO for the green LED.bluePin
- GPIO for the blue LED.- Throws:
RuntimeIOException
- If an I/O error occurred.
-
-
Method Details
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
getValues
Get the state of all LEDs.- Returns:
- Boolean array (red, green, blue).
- Throws:
RuntimeIOException
- If an I/O error occurred.
-
setValues
Set the state of all LEDs.- Parameters:
red
- Red LED state.green
- Green LED state.blue
- Blue LED state.- Throws:
RuntimeIOException
- If an I/O error occurred.
-
on
Turn all LEDs on.- Throws:
RuntimeIOException
- If an I/O error occurred.
-
off
Turn all LEDs off.- Throws:
RuntimeIOException
- If an I/O error occurred.
-
toggle
Toggle the state of all LEDs.- Throws:
RuntimeIOException
- If an I/O error occurred.
-