Class PwmLed

java.lang.Object
All Implemented Interfaces:
OutputDeviceInterface, java.io.Closeable, java.lang.AutoCloseable

public class PwmLed
extends PwmOutputDevice
PWM controlled LED. @see com.diozero.sampleapps.PwmLedTest PwmLedTest
  • Constructor Details

  • Method Details

    • blink

      public void blink() throws RuntimeIOException
      Blink the LED on and off indefinitely.
      Throws:
      RuntimeIOException - If an I/O error occurred.
    • blink

      public void blink​(float onTime, float offTime, int iterations, boolean background) throws RuntimeIOException
      Blink the LED on and off repeatedly.
      Parameters:
      onTime - On time in seconds.
      offTime - Off time in seconds.
      iterations - Number of iterations. Set to <0 to blink 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.
    • pulse

      public void pulse() throws RuntimeIOException
      Pulse the LED on and off indefinitely in a background thread with a fade time of 1 second.
      Throws:
      RuntimeIOException - If an I/O error occurred.
    • pulse

      public void pulse​(float fadeTime, int steps, int iterations, boolean background) throws RuntimeIOException
      Pulse the LED on and off repeatedly.
      Parameters:
      fadeTime - Time in seconds from fully on to fully off.
      steps - Number of steps between fully on to fully off.
      iterations - Number of times to fade in and out.
      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.
    • isLit

      public boolean isLit() throws RuntimeIOException
      Return true if the PWM value is >0.
      Returns:
      True if >0, false if 0.
      Throws:
      RuntimeIOException - If an I/O error occurred.