Members
-
<readonly> value :number
-
Description
The current value of the LEDDetails
-
<readonly> isOn :boolean
-
Description
Wether the LED is onDetails
-
<readonly> isRunning :boolean
-
Description
True if the LED is blinking, pulsing or animatingDetails
Methods
-
configure( options ) → {LED}
-
Description
Configure an LEDParameters
Name Type Description options
object Device configuration options Name Type Attributes Default Description sink
number <optional> false True if an element is wired for sink drive Returns
Examples
import LED from "j5e/led"; const led = await new LED(14); led.configure({ sink: true }); // With sink: true, led.on() sets pin 14 low led.on();
Details
-
on() → {LED}
-
Description
Turn an led onReturns
Examples
import LED from "j5e/led"; const led = await new LED(12); led.on();
Details
-
off() → {LED}
-
Description
Turn an led offReturns
Examples
import LED from "j5e/led"; import {timer} from "j5e/fn"; const led = await new LED(12); led.on(); // Wait one second and turn the led off timer.setTimeout(function() { led.off(); }, 1000);
Details
-
toggle() → {LED}
-
Description
Toggle the on/off state of an ledReturns
Examples
import LED from "j5e/led"; import {timer} from "j5e/fn"; const led = await new LED(12); led.toggle(); // It's on! // Wait one second and turn the led off timer.setTimeout(function() { led.toggle(); // It's off! }, 1000)
Details
-
blink( duration, callback ) → {LED}
-
Description
Blink the LED on a fixed intervalParameters
Name Type Default Description duration
Number 100 Time in ms on, time in ms off callback
function Method to call on blink Returns
Examples
import LED from "j5e/led"; const led = await new LED(12); led.blink(1000);
Details
-
brightness( value ) → {LED}
-
Description
Set the brightness of an ledParameters
Name Type Description value
Number Brightness value [0, 1] Returns
Examples
import LED from "j5e/led"; const led = await new LED(12, { pwm: true }); led.brightness(0.5);
Details
-
intensity( value ) → {LED}
-
Description
Set the brightness of an led 0-100Parameters
Name Type Description value
Integer Brightness value [0, 100] Returns
Examples
import LED from "j5e/led"; const led = await new LED(12, { pwm: true }); led.intensity(50);
Details
-
fade( val [, time [, callback ] ] ) → {LED}
-
Description
Fade an led from its current value to a new value (Requires ```pwm: true```)Parameters
Name Type Attributes Default Description val
Number Target brightness value time
Number <optional> 1000 Time in ms that a fade will take callback
function <optional> A function to run when the fade is complete Returns
Examples
import LED from "j5e/led"; const led = await new LED(12, { pwm: true }); led.fade(512);
Details
-
fadeIn( [ time [, callback ] ] ) → {LED}
-
Description
fadeIn Fade an led in to full brightness (Requires ```pwm: true```)Parameters
Name Type Attributes Default Description time
Number <optional> 1000 Time in ms that a fade will take callback
function <optional> A function to run when the fade is complete Returns
Examples
import LED from "j5e/led"; const led = await new LED(12, { pwm: true }); led.fadeIn(500);
Details
-
fadeOut( [ time [, callback ] ] ) → {LED}
-
Description
fadeOut Fade an led out until it is off (Requires ```pwm: true```)Parameters
Name Type Attributes Default Description time
Number <optional> 1000 Time in ms that a fade will take callback
function <optional> A function to run when the fade is complete Returns
Examples
import LED from "j5e/led"; const led = await new LED(12, { pwm: true }); led.on(); led.fadeOut(500);
Details
-
pulse( [ time [, callback ] ] ) → {LED}
-
Description
Pulse the LED in and out in a loop with specified time using ```inOutSine``` easing (Requires ```pwm: true```)Parameters
Name Type Attributes Default Description time
number <optional> 1000 Time in ms that a fade in/out will elapse callback
function <optional> A function to run each time the direction of pulse changes Returns
Examples
import LED from "j5e/led"; const led = await new LED(12, { pwm: true }); led.pulse(500);
Details
-
animate( options ) → {LED}
-
Description
Animate the LED by passing in a segment options objectParameters
Name Type Description options
Object (See j5e's Timeline and Tweening Tools) Returns
Examples
import LED from "j5e/led"; const led = await new LED(12, { pwm: true }); led.animate({ duration: 4000, cuePoints: [0, 0.33, 0.66, 1], keyFrames: [0, 0.75, 0.25, 1], loop: true, metronomic: true });
Details
-
stop() → {LED}
-
Description
stop Stop the led from blinking, pulsing, fading, or animatingReturns
Examples
Pulse an LED and then stop after five seconds import {timer} from "j5e/fn"; import LED from "j5e/led"; const led = await new LED(12, { pwm: true }); led.pulse(500); // Stop pulsing after five seconds timer.setTimeout(function() { led.stop(); }, 5000);
Details