PWMLED

PWMLED

new PWMLED(pin, active_highopt, initial_valueopt, frequencyopt)

Source:
Represents a light emitting diode (LED) with variable brightness. A typical configuration of such a device is to connect a GPIO pin to the anode (long leg) of the LED, and the cathode (short leg) to ground, with an optional resistor to prevent the LED from burning out.
Parameters:
Name Type Attributes Description
pin int The GPIO pin which the LED is attached to.
active_high boolean <optional>
If ``true`` (the default), the on method will set the GPIO to HIGH. If ``false``, the on method will set the GPIO to LOW (the off method always does the opposite).
initial_value float <optional>
If ``0`` (the default), the LED will be off initially. Other values between 0 and 1 can be specified as an initial brightness for the LED. Note that ``undefined`` cannot be specified (unlike the parent class) as there is no way to tell PWM not to alter the state of the pin.
frequency int <optional>
The frequency (in Hz) of pulses emitted to drive the LED. Defaults to 100Hz.

Extends

Methods

Source:
Inherited From:
Make the device turn on and off repeatedly.
Parameters:
Name Type Attributes Description
on_time float <optional>
Number of seconds on. Defaults to 1 second.
off_time float <optional>
Number of seconds off. Defaults to 1 second.
fade_in_time float <optional>
Number of seconds to spend fading in. Defaults to 0.
fade_out_time float <optional>
Number of seconds to spend fading out. Defaults to 0.
n int <optional>
Number of times to blink; ``undefined`` (the default) means forever.
{@callback} [callback] - Function to be called after n loops.

close()

Source:
Inherited From:
Stop any actions such as blink and unlink from pin.

frequency(valueopt) → {int}

Source:
Inherited From:
Sets or Gets the device frequency.
Parameters:
Name Type Attributes Description
value int <optional>
The new frequency for the device.
Returns:
- If value is undefined then the current device frequency is returned.
Type
int

is_active() → {boolean}

Source:
Inherited From:
Returns:
- If the device has a value other than 0 then true.
Type
boolean

is_lit() → {boolean}

Source:
Returns:
- Alias for is_active.
Type
boolean

off()

Source:
Inherited From:
Turn the device off.

on()

Source:
Inherited From:
Turn the device fully on.

pulse(fade_in_timeopt, fade_out_timeopt, nopt, {@callback})

Source:
Inherited From:
Make the device fade in and out repeatedly.
Parameters:
Name Type Attributes Description
fade_in_time float <optional>
Number of seconds to spend fading in. Defaults to 0.
fade_out_time float <optional>
Number of seconds to spend fading out. Defaults to 0.
n int <optional>
Number of times to blink; ``undefined`` (the default) means forever.
{@callback} [callback] - Function to be called after n loops.

toggle()

Source:
Inherited From:
Toggle the state of the device. If the device is currently off (value` is 0.0), this changes it to "fully" on (`value` is 1.0). If the device has a duty cycle (`value`) of 0.1, this will toggle it to 0.9, and so on.

value(valueopt) → {float}

Source:
Inherited From:
The duty cycle of the PWM device. 0.0 is off, 1.0 is fully on. Values in between may be specified for varying levels of power in the device.
Parameters:
Name Type Attributes Description
value float <optional>
When defined then sets the device duty cycle.
Returns:
- When value is undefined then the current duty cycle is returned.
Type
float